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();
posted @ 2024-05-08 10:39  pine007  阅读(252)  评论(0编辑  收藏  举报