title: SQL Server query: Incorrect syntax near the keyword 'Group'
body: <p>I have two tables <code>TableA</code> and <code>TableB</code>. They have a join on <code>TableA.refID = TableB.SomeID</code>, then some other columns (<code>TableA.time</code>, <code>TableB.kind</code>).</p>
  
  <p>I would like make a query, order by time a and group them by type.</p>
  
  <p>This is the query I use (modified for a best showcase)</p>
  
  <pre><code>SELECT  
     *, TableA.time AS B, TableB.type AS A
  FROM       
     TableB  
  INNER JOIN
     TableB ON TableB.SomeID = TableA.refID
  ORDER BY 
     B
  GROUP BY 
     TableB.type
  </code></pre>
  
  <p>I get this exception:</p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'Group'.</p>
  </blockquote>
  
  <p>How should I correct it?</p>