ahmedrahil786

GrabPay by city Analyses Query - Rahil

Jun 21st, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. ### Reservations with Grabpay vs Card Pay - Divided by Regions
  2. select
  3. Date(r.return_at + interval '8' hour) as date,
  4. z.city as city,
  5. count(distinct r.id) as resv,
  6. count(distinct case when p.paid_type = 'card' then p.member_id end) as cardpaid,
  7. count(distinct case when p.paid_type = 'eWallet' then p.member_id end) as grabpay
  8. from reservations r
  9. join zones z on r.start_zone_id = z.id
  10. right join payments p on p.reservation_id = r.id
  11. join members m on r.member_id = m.id
  12. where r.return_at >= '2019-4-1'
  13. and r.state = 'completed'
  14. and z.city in ('KL','JB','PG','SL')
  15. and m.state = 'normal'
  16. and m.imaginary = 'normal'
  17. group by date,city;
  18.  
  19. ##### Finding MFTs Tagged to Members paid through "Grabpay" , Divided by "City"
  20.  
  21. select
  22. Date(r.start_at + interval '8' hour) as date,
  23. count(distinct r.member_id) as mid,
  24. z.city as city
  25. from reservations r
  26. Right join payments p on p.member_id = r.member_id
  27. join members m on m.id = r.member_id
  28. join zones z on r.start_zone_id = z.id
  29. where m.created_at + interval '8' hour >= '2019-6-12'
  30. and p.paid_type = 'eWallet'
  31. group by date,city
Advertisement
Add Comment
Please, Sign In to add comment