Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

sum multiple fields separately in laravel

$customer = FinanceSale::select(
  DB::raw('SUM(sub_total) as total_sales'),
  DB::raw('SUM(discount) as d'),
)
->where('customer_id', $id)
->groupBy('customer_id')
->first();
 
PREVIOUS NEXT
Tagged: #sum #multiple #fields #separately #laravel
ADD COMMENT
Topic
Name
5+7 =