title: The multi-part identifier could not be bound - GROUP BY
body: <p>I'm pretty new to SQL. I have this code that works without the final <code>GROUP BY</code> line. With it, I receive the <code>multi-part identifier could not be bound.</code> I need to <code>GROUP BY L1_DESC, L2_DESC and L3_DESC</code>, but cannot figure out where to put this in the code.</p>
  
  <pre><code>SELECT * FROM (
  SELECT d.*
  ,c.COL_DESC
  --,v.VAL_N
  ,an.CUST_ACCT_NBR
  ,s.L1_DESC, s.L2_DESC, s.L3_DESC
  FROM dbo.ECL_SEG101_DATA d
  INNER JOIN (
  SELECT SITE_ID
  ,max(SRC_BATCH_ID) AS SRC_BATCH_ID
  FROM dbo.ECL_SEG101_DATA d
  WHERE SRC_ID = 'K12'
  GROUP BY SITE_ID) d1
         ON d1.SRC_BATCH_ID = d.SRC_BATCH_ID
         AND d1.SITE_ID = d.SITE_ID
  INNER JOIN dbo.ECL_SEG002_EXT_DATA_VAR v
         ON d.SRC_BATCH_ID = v.LIST_ID
         AND d.SRC_REC_ID = v.ROW_ID
  LEFT OUTER JOIN dbo.INS_REF006_ACCT an
            ON d.SITE_ID = an.LOC_KEY
  INNER JOIN dbo.ECL_SEG101_SEGMENT s
        ON d.SITE_SEG_LVLS_ID = s.LVLS_ID
  INNER JOIN dbo.ECL_SEG002_EXT_COL c
         ON v.COL_ID = c.COL_ID
  WHERE d.Site_Data_Ord = '1') p
  GROUP BY c.COL_DESC, an.CUST_ACCT_NBR, s.L1_DESC, s.L2_DESC, s.L3_DESC
  </code></pre>