title: Trouble using subqueries and/or with
body: <p>Here's the deal I have one column to identify quarter and one to identify year. I need to group the sum of a column by another column, how do I join the with statements or use the subqueries properly? Having troubles?</p>
  
  <p>Here is me trying with with, im not sure how to join these statements and have the column company name out front?</p>
  
  <pre><code>WITH Q219 (Comp,Q219) AS
  (
  SELECT [Company Name - As Is],SUM(NSB) FROM [insta].[dbo].[sample$]
  WHERE Quarter = 'Q2' AND Year = 2019
            GROUP BY [Company Name - As Is]
  ),
   Q319 (Comp,Q319) AS
  (
  SELECT [Company Name - As Is],SUM(NSB) FROM [insta].[dbo].[sample$]
  WHERE Quarter = 'Q2' AND Year = 2019
            GROUP BY [Company Name - As Is]
  ),
   Q318 (Comp,Q318) AS
  (
  SELECT [Company Name - As Is],SUM(NSB) FROM [insta].[dbo].[sample$]
  WHERE Quarter = 'Q3' AND Year = 2018
            GROUP BY [Company Name - As Is]
  )
  
   select Q318,Q219,Q319 from Q318,Q219,Q319
   go
  </code></pre>
  
  <p>Also tried with subqueries but can't get it to work</p>
  
  <pre><code>SELECT 
  
  Q219 = 
  (SELECT SUM(NSB) FROM [insta].[dbo].[sample$]
          WHERE Quarter = 'Q2' AND Year = 2019
            GROUP BY [Company Name - As Is]),
  Q319 = ....
  
  
    FROM [insta].[dbo].[sample$]
  </code></pre>