我需要获得总计数才能显示在我的页面中。
我可以运行这个 & 循环 & 得到总数
DB::table('table1')
->select((DB::raw('MAX(score)')))
->where('status', 1)
->groupBy('user_id')
->get();
但是这个查询将在一个查询中给我计数并且我不需要运行任何额外的循环来获得总数。
SELECT COUNT( * ) FROM (
SELECT MAX( score ) FROM table1
WHERE status =1
GROUP BY user_id
) AS totalCounter
我想如何在 Laravel 4 中运行这个 RAW 查询?