title: Get number of orders made for each hour in a certain year
body: <p>In an e-commerce website, I have a database that contains the following fields:</p>
  
  <pre><code>id
  date_purchased
  ...
  </code></pre>
  
  <p>The field <code>date_purchased</code> has the current format : <code>2018-02-14 16:27:37</code>(year-month-day hours-minutes-seconds)</p>
  
  <p>I would like to get, for the year 2018 for example, ordered by ASC, the number of orders made for each hour. </p>
  
  <p>I can't figure out how to order by a certain year, and count the number of orders made each hour of that year. </p>
  
  <p>Something like : </p>
  
  <pre><code>SELECT count(*) 
  FROM table 
  WHERE (
      SELECT * 
      FROM table 
      GROUP BY DATEPART(hour, [date_purchased]) ASC
  ) 
  GROUP BY year(date_purchased) ASC
  </code></pre>