title: How do I perform a GROUP BY on an aliased column in SQL Server?
body: <p>I'm trying to perform a <em>group by</em> action on an aliased column (example below) but can't determine the proper syntax.</p>
  <pre><code>SELECT       LastName + ', ' + FirstName AS 'FullName'
  FROM         customers
  GROUP BY     'FullName'
  </code></pre>
  <p>What is the correct syntax?</p>
  <p>Extending the question further (I had not expected the answers I had received) would the solution still apply for a CASEed aliased column?</p>
  <pre><code>SELECT       
      CASE
          WHEN LastName IS NULL THEN FirstName
          WHEN LastName IS NOT NULL THEN LastName + ', ' + FirstName
      END AS 'FullName'
  FROM         customers
  GROUP BY     
      LastName, FirstName
  </code></pre>
  <p>And the answer is yes it does still apply.</p>