ahmedrahil786

MAU by Zones

Jun 19th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. select
  2. weekofyear(r.return_at + interval '8' hour) as week,
  3. r.start_zone_id as zid,
  4. count(distinct case when r.state NOT IN ('canceled', 'fail') then r.member_id end) as ActiveMembers,
  5. count(distinct case when r.state NOT IN ('canceled', 'fail') then r.id end) as resv
  6. from reservations r
  7. join members m
  8. on m.id = r.member_id and m.email not like '%socar.my%' and m.imaginary = 'normal'
  9. where r.return_at + interval '8' hour >= @start
  10. group by 1,2
  11. order by 1 asc
Advertisement
Add Comment
Please, Sign In to add comment