laravel groupby count 分组后统计数量
- 分组后统计数量
$query = DB::table("accessories_outbound as a")
->join("accessories_outbound_details as b", 'b.acc_outbound_no', '=', 'a.acc_outbound_no')
->groupBy(['a.acc_outbound_no']);
// 分组后计数
$total = DB::table(DB::raw("({$query->toSql()}) as sub"))
->mergeBindings($query)
->count();