ahmedrahil786

Reservation Split by month, year and Gender- Rahil for Sufia

Sep 24th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. select
  2. year(r.return_at + interval '8' hour) as year,
  3. month(r.return_at + interval '8' hour) as month,
  4. ifnull(dl.gender,"") as gender,
  5. count(r.id) as resv
  6. from reservations r
  7. left join members m on m.id = r.member_id
  8. left join driver_licenses dl on dl.member_id = m.id
  9. where m.imaginary in ('sofam', 'normal')
  10. and r.member_id not in ('125', '127')
  11. and r.start_zone_id not in (2, 3, 101)
  12. and r.state in ('completed')
  13. and year(r.return_at + interval '8' hour) is not null
  14. and dl.gender not in ('unknown')
  15. group by 1,2,3
  16. order by 1 desc
Advertisement
Add Comment
Please, Sign In to add comment