ahmedrahil786

card vs Grabpay - Rahil

Jun 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. select
  2. Date(r.return_at + interval '8' hour) as date,
  3. z.city as city,
  4. count(distinct r.id) as resv,
  5. count(distinct case when p.paid_type = 'card' then p.reservation_id end) as cardpaid,
  6. count(distinct case when p.paid_type = 'eWallet' then p.reservation_id end) as grabpay
  7. from reservations r
  8. join zones z on r.start_zone_id = z.id
  9. right join payments p on p.reservation_id = r.id
  10. join members m on r.member_id = m.id
  11. where r.return_at >= '2019-4-1'
  12. and r.state = 'completed'
  13. and z.city in ('KL','JB','PG','SL')
  14. and m.state = 'normal'
  15. and m.imaginary = 'normal'
  16. group by date,city
Advertisement
Add Comment
Please, Sign In to add comment