title: SQL Group by Year
body: <p>This is my query.</p>
  
  <pre><code>select CONVERT(varchar, cast(date as datetime), 3)
  from shoptransfer 
  group by year (date)
  </code></pre>
  
  <p>I want to group by the year part of the date (varchar) column, however I get the following error:</p>
  
  <blockquote>
    <p>Column 'shoptransfer.Date' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</p>
  </blockquote>
  
  <p>How do I group by the year part of the date column?</p>