📜  laravel group by with where 子句 - PHP 代码示例

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

代码示例2
$groupedSalesCampaign = Order::with('Campaign')
            ->where('isapproved','=','Y')
            ->groupBy('campaign_id')
            ->orderBy(DB::raw('COUNT(id)','desc'))
            ->get(array(DB::raw('COUNT(id) as totalsales'),'campaign_id'));