title: MySQL group by date DATE_FORMAT() function
body: <p>I have the following query: </p>
  
  <pre><code>SELECT DATE_FORMAT(order_completed, "%c/%Y") AS Month, COUNT(*) AS Total_Transactions, SUM(order_total_grand) as Total_Spend FROM `shop_orders` GROUP BY DATE_FORMAT(order_completed, "%c/%Y") DESC
  </code></pre>
  
  <p>Which outputs the following table:</p>
  
  <p><a href="https://i.stack.imgur.com/QmeOd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QmeOd.png" alt="Table"></a></p>
  
  <p>How can I sort the table by date correctly? </p>