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

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

代码示例1
$users = User::select('users*', 'analytics.*', DB::raw('SUM(analytics.revenue) As revenue'))
         ->leftJoin('analytics', 'analytics.user_id', '=', 'users.id')
         ->where('analytics.date', Carbon::today()->toDateString())
         ->get();