title: Laravel raw query that counts results per month and aggregates
body: <p>I have the following query</p>
  
  <pre><code>$this-&gt;builder = (DB::table('sales')
          -&gt;select(DB::raw('DATE_FORMAT(sale_date, "%M") as sale_date'), DB::raw('count(*) as sales'))
          -&gt;where('sale_date', '&gt;', $lookback-&gt;toDateTimeString())
          -&gt;orderBy('sale_date', 'asc')
          -&gt;groupBy('sale_date'));
  </code></pre>
  
  <p>Despite specifying the month <code>%M</code> to group the results, it's just counting each date and giving the label as the month, so something like this:</p>
  
  <pre><code>sale_date , sales
   August   ,  1
   August   ,  3
   August   ,  2
  </code></pre>
  
  <p>Instead of what I expect:</p>
  
  <pre><code>sale_date , sales
   August   ,  6
  </code></pre>
  
  <p>What am I doing wrong here, I do have the option of just summing those within the javascript once I get the results from the API, however I don't think it should be necessary right?</p>