ahmedrahil786

F8-Duration_distribution

May 19th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. use socar_malaysia;
  2. set @startdate = date_sub(CURDATE(), interval 2 month);
  3. set @startdate2 = date_sub(CURDATE(), interval 1 day);
  4.  
  5. select
  6. distinct r.id as rid,
  7. round(sum(timestampdiff(minute, r.start_at, r.end_at)/60),2) as dur,
  8. count(r.id) as nuse
  9. from reservations r , members m
  10.  
  11. Where
  12. r.member_id = m.id
  13. and m.imaginary in ('sofam', 'normal')
  14. and r.member_id not in ('125', '127')
  15. and r.state in ('completed')
  16. and r.return_at + interval 8 hour >= @startdate
  17. and r.return_at + interval 8 hour <= @startdate2
  18.  
  19. group by rid
  20. order by dur desc
  21. ;
Advertisement
Add Comment
Please, Sign In to add comment