title: Using aggregate methods( SUM as of here) in laravel query for complex queries
body: <p>I have to run a query to find out the total orders for each quantity as  </p>
  
  <pre><code>  SELECT userorders.`delivered` as delivered_status, items.`name` as itemname, 
  sizes.`size` as sizename,SUM(userorders.`order_qty`) as order_quantity, 
  sizes.`qty` as stockremaining FROM userorders inner join sizes on 
  userorders.`size`=sizes.`id` inner join items on  sizes.`item_id`=items.`id`
   WHERE 1 group by userorders.`delivered`, userorders.`size`;
  </code></pre>
  
  <p>Roughly, its laravel equivalent is</p>
  
  <pre><code> $userorders = DB::table('userorders')
              -&gt;join('sizes', 'userorders.size', '=', 'sizes.id')
              -&gt;join('items', 'sizes.item_id', '=', 'items.id')
              -&gt;join('categories', 'items.category_id', '=', 'categories.id')
              -&gt;select('SUM(userorders.order_qty) as order_quantity','userorders.delivered as delivered_status', 'items.name as itemname','categories.name as categoryname', 'sizes.size as sizename','sizes.qty as stockremaining')
              -&gt;groupBy('userorders.delivered', 'userorders.size')
              -&gt;get();
  </code></pre>
  
  <p>But, it seems laravel doesnt support aggregate parameters.
  I found out that for getting just the aggregate quantity we could use it as</p>
  
  <pre><code>$userorders = DB::table('userorders')
                  -&gt;join('sizes', 'userorders.size', '=', 'sizes.id')
                  -&gt;join('items', 'sizes.item_id', '=', 'items.id')
                  -&gt;join('categories', 'items.category_id', '=', 'categories.id')
                  -&gt;SUM('userorders.order_qty');
  </code></pre>
  
  <p>But it seems not to be working in my case for getting the sum as well as other parameters too.
  Could someone suggest me the way how to make it work??</p>