Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @yearmonth = 201908;
- select m.id, m.first_name, m.last_name, m.email, ma.phone,
- sum(timestampdiff(minute,r.occupy_start_at,r.occupy_end_at)) as total_minutes_booked,
- count(distinct r.id) as bookings
- from members m
- join member_appendixes ma on ma.member_id = m.id
- join reservations r on r.member_id = m.id
- where r.state IN ('completed','returnDelayed')
- and m.imaginary NOT IN ('wash','commonBlock','accident','d2dAgent','test')
- and extract(year_month from r.occupy_start_at) = @yearmonth
- group by 1, ma.phone
Advertisement
Add Comment
Please, Sign In to add comment