Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql select sum group by id laravel join

$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();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #select #sum #group #id #laravel #join
ADD COMMENT
Topic
Name
2+4 =