Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel group by with where clause

$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'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #group #clause
ADD COMMENT
Topic
Name
9+8 =