title: Create view with subquery
body: <p>I'm trying to create a view in SQL Server but the syntax keeps give me issues due to the sub query I'm using. Basically I need the results of select statement below to be in a view. How would I go about this syntactically? </p>
  
  <pre><code>SELECT Sub_Company, GL_Account, CAST(SUM(Debits) AS DECIMAL(18,2)) AS Debits, 
         CAST(SUM(Credits) AS DECIMAL(18,2)) AS Credits, CAST(SUM([P&amp;L_Impact]) AS DECIMAL(18,2)) AS [P&amp;L_Impact], COUNT(*) AS Record_Count
  FROM (SELECT *
        FROM [FL_SQL_Training].[dbo].[Combined_GL]
        WHERE Company = 'US' AND GL_Source = 'Consolidation'
       ) A
  WHERE GL_Journal_Header_Description LIKE '%UK%' OR
        GL_Journal_Header_Description LIKE '%CAD%' OR
        GL_Journal_Header_Description LIKE '%MEX%' OR
        GL_Journal_Header_Description LIKE '%Hon%'
  GROUP BY Sub_Company, GL_Account
  </code></pre>