Advertisement
ahmedrahil786

Age Group Vs Bookings

Mar 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. select
  2. m.id as memberid,
  3. dl.birthday as birthday,
  4. dl.state as state,
  5. count(distinct r.id) as bookings
  6. from members m
  7.  
  8. join driver_licenses dl
  9. on m.id = dl.member_id
  10.  
  11. left outer join reservations r
  12. on r.member_id = m.id
  13.  
  14.  
  15. where r.state = 'completed'
  16. and CONVERT_TZ(r.start_at, '+00:00', '+8:00') >= '2018-10-01 00:00'
  17. and CONVERT_TZ(r.end_at, '+00:00', '+8:00') < '2019-03-01 00:00'
  18. and m.imaginary = 'normal'
  19. and m.state = 'normal'
  20. and dl.birthday != 0
  21.  
  22. group by m.id
  23.  
  24. order by bookings desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement