📜  在 laravel 中分别对多个字段求和 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:50.130000             🧑  作者: Mango

代码示例1
$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();