ahmedrahil786

Leon - number of reservation per week

Jul 18th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. select
  2. distinct r.member_id,
  3. count(distinct r.id)
  4. from reservations r
  5. left join members m on m.id = r.member_id
  6. where r.state in ('completed','inUse')
  7. and r.start_at + interval '8' hour > '2019-7-8'
  8. and r.start_at + interval '8' hour < '2019-7-15'
  9. and m.state = 'normal'
  10. and m.imaginary = 'normal'
  11. group by r.member_id
  12. order by 2 desc;
Advertisement
Add Comment
Please, Sign In to add comment