Guest User

Untitled

a guest
Sep 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. select `u`.*, count(t.empid) as totalassignedtask from `users` as `u` left join `tasks` as `t` on `t`.`empid` = `u`.`id` where `u`.`role` = 'user' group by `t`.`empid`
  2.  
  3. $allemp = DB::table('users as u')
  4. ->leftJoin('tasks as t','t.empid','=','u.id')
  5. ->where('u.role','=','user')
  6. ->select('u.*',DB::raw('count(t.empid) as totalassignedtask'))
  7. ->groupBy('t.empid')
  8. ->get();
  9.  
  10. 'strict' => true,
  11.  
  12. strict => false
  13.  
  14. $allemp = DB::table('users as u')
  15. ->join('tasks as t','t.empid','=','u.id')
  16. ->where('u.role','=','user')
  17. ->select('u.id','u.name','u.email',DB::raw('count(t.empid) as totalassignedtask'))
  18. ->groupBy('u.id','u.name','u.email')
  19. ->orderBy('totalassignedtask', 'asc')
  20. ->get();
Add Comment
Please, Sign In to add comment