title: How to use sum and groupBy in laravel query
body: <p>I want to sum stock in purchase table with different unit name in Laravel 5.6 This is my query:</p>
  
  <pre><code>DB::select("select brand_name,unit_name, sum(now_stock) as stock from purchases where category_id = 2 group By(unit_name)");
  </code></pre>
  
  <p>When I run it in mysql then it is OK, but when I use it in laravel then an error is shown.</p>
  
  <p><strong>I want as out put in laravel blade file</strong></p>
  
  <pre><code> 1. brand_name ...Unit_name ...Stock
   2. BSRM ...  ........    1.2     ....  .. ..........25  
   3. KSRM..............1.5...................50
  </code></pre>
  
  <p>How can I write this query?</p>