I am trying to convert the following query to laravels using query builder but having some issue with group by clause and sum aggregated functions
SELECT code, SUM(quantity) as quantity, SUM(sale_price) as price
FROM `orders` o
GROUP By code
I have tried this
$args['orders'] = DB::table('orders')
->havingRaw('sum(sale_price)')
->havingRaw('code')
->where([ 'shop_id' => $shop_id ])
->groupBy('code')
->get();
via Waleed