Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- cp.name,
- count(distinct c.member_id) as applies,
- count(distinct c.reservation_id) as bookings,
- count(distinct r.member_id) as ActiveMembers
- from coupons c
- left outer join reservations r
- on r.id = c.reservation_id
- join members m
- on m.id = c.member_id and m.imaginary = 'normal'
- join coupon_policies cp
- on c.coupon_policy_id = cp.id
- where c.coupon_policy_id IN (655, 656)
- #and c.member_id IN (select ch.member_id from charges ch where ch.kind = 'subscriptionFee' and ch.created_at + interval '8' hour >= '2019-5-14')
- #and r.member_id IN (select ch.member_id from charges ch where ch.kind = 'subscriptionFee' and ch.created_at + interval '8' hour >= '2019-5-14')
- group by 1;
Add Comment
Please, Sign In to add comment