Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- distinct r.member_id,
- count(distinct r.id)
- from reservations r
- left join members m on m.id = r.member_id
- where r.state in ('completed','inUse')
- and r.start_at + interval '8' hour > '2019-7-8'
- and r.start_at + interval '8' hour < '2019-7-15'
- and m.state = 'normal'
- and m.imaginary = 'normal'
- group by r.member_id
- order by 2 desc;
Advertisement
Add Comment
Please, Sign In to add comment