📜  sql select sum group by id laravel - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:00.451000             🧑  作者: Mango

代码示例1
Document::groupBy('users_editor_id')
   ->selectRaw('sum(no_of_pages) as sum, users_editor_id')
   ->pluck('sum','users_editor_id');

   // originally lists(), which was deprecated in favour of pluck in 5.2
   // and dropped completely in 5.3
   // ->lists('sum','users_editor_id');


// returns array like this:
array(
  users_editor_id => sum,
  ...
)