是否可以在laravel查询中使用COALESCE.
$multipleitems = DB::table('votes')
->select('masterItemId',DB::raw('sum(votes) as voteSum'))
->whereBetween('voteDate',array($startDate,$endDate))
->where($condition)
->groupBy('masterItemId')
->get();
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我希望得到每个项目及其总票数.如果没有投票,我想得到'0'.
但在上面的代码中,它返回至少有1票的项目.是否有任何方法可以在laravel中完成此操作?