Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- m.id as memberid,
- dl.birthday as birthday,
- dl.state as state,
- count(distinct r.id) as bookings
- from members m
- join driver_licenses dl
- on m.id = dl.member_id
- left outer join reservations r
- on r.member_id = m.id
- where r.state = 'completed'
- and CONVERT_TZ(r.start_at, '+00:00', '+8:00') >= '2018-10-01 00:00'
- and CONVERT_TZ(r.end_at, '+00:00', '+8:00') < '2019-03-01 00:00'
- and m.imaginary = 'normal'
- and m.state = 'normal'
- and dl.birthday != 0
- group by m.id
- order by bookings desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement