Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. SELECT Event.id, sum(Attendees.total_raised), sum(Attendees.total_hours)
  2. FROM Events JOIN Attendees ON Events.id = Attendees.event_id
  3. GROUP BY Event.id
  4.  
  5. $q = DB::table('events')
  6. ->join('attendees', 'events.id', '=', 'attendees.event_id')
  7. ->sum('total_raised')
  8. ->sum('total_hours');
  9.  
  10. ...
  11.  
  12. ->get(
  13. array(
  14. 'events.id',
  15. DB::raw('SUM(attendees.total_raised)'),
  16. DB::raw('SUM(attendees.total_hours)')
  17. )
  18. );
  19.  
  20. $query = DB::table('events')->join('attendees', 'events.id', '=', 'attendees.event_id');
  21.  
  22. $raised = $query->sum( 'total_raised' );
  23.  
  24. $hours = $query->sum( 'total_hours' );
  25.  
  26. $result = DB::table('events')->join('attendees', 'events.id', '=', 'attendees.event_id')
  27. ->get( array(
  28. DB::raw( 'SUM(attendees.total_raised) AS raised' ),
  29. DB::raw( 'SUM(attendees.total_hours) AS hours' ),
  30. ));
  31.  
  32. $result = self::select("*", DB::raw('SUM(auction_amount) as total_auction_amount') , DB::raw('SUM(commission_amount) as total_commission_amount'),
  33. DB::raw('SUM(deposit_amount) as total_deposit_amount'))
  34. ->groupBy('cp_user_id')
  35. ->get()
  36. ->toArray();
  37.  
  38. $result = self::select("*", DB::raw('SUM(auction_amount) as total_auction_amount') , DB::raw('SUM(Attendees.total_raised) as total_raised'),
  39. DB::raw('SUM(Attendees.total_hours) as total_hours'))
  40. ->with('Attendees')
  41. ->groupBy('id')
  42. ->get()
  43. ->toArray();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement