title: How to turn JOINS into Subqueries without breaking the SQL logic
body: <p>I have performance issues while using multiple joins in T-SQL and if anyone can help me to turn these joins into sub-queries would be nice.</p>
  
  <p>Whenever i try to change the join into subquery, i'm loosing the name declaration for the specific table. For instance if i try to turn the Album join (which is the first join on code below) into subquery i'm loosing the alias "AS a" and the "a.Title AS Album" stopped working so i have no idea how this would be done. If anyone gives me an example how should it work for one of the cases i suppose i will be able to reconstruct all of them.</p>
  
  <blockquote>
    <p>SQL</p>
  </blockquote>
  
  <pre><code>SELECT
      t.TrackId, 
      t.[Name] AS Track, 
      a.Title AS Album, 
      aa.[Name] AS Artist, 
      p.[Name] AS Playlist,
      m.[Name] AS MediaType,
      il.UnitPrice AS InvoicePrice,
      CONCAT(c.FirstName, ' ', c.LastName) AS CustomerName,
      CONCAT(e.FirstName, ' ', e.LastName) AS ResponsibleEmployeeName
  FROM dbo.Track AS t
  INNER JOIN dbo.Album AS a
      ON t.AlbumId = a.AlbumId
  INNER JOIN dbo.Artist AS aa
      ON a.ArtistId = aa.ArtistId
  INNER JOIN dbo.PlaylistTrack AS plt
      ON t.TrackId = plt.TrackId
  INNER JOIN dbo.Playlist AS p
      ON p.PlaylistId = plt.PlaylistId
  INNER JOIN dbo.MediaType AS m
      ON t.MediaTypeId = m.MediaTypeId
  INNER JOIN dbo.InvoiceLine AS il
      ON t.TrackId = il.TrackId
  INNER JOIN dbo.Invoice AS i
      ON il.InvoiceId = i.InvoiceId
  INNER JOIN dbo.Customer AS c
      ON i.CustomerId = c.CustomerId
  INNER JOIN dbo.Employee AS e
      ON c.SupportRepId = e.EmployeeId
  WHERE m.[Name] LIKE '%audio%'
  ORDER BY t.[Name] ASC
  </code></pre>