Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select A.date, A.mid, B.rid from
- (select
- distinct c.member_id as mid,
- Date(c.created_at + interval 8 hour) as date
- from charges c left join members m on m.id = c.member_id
- where c.kind = 'subscriptionFee'
- and Date(c.created_at + interval 8 hour) > '2019-01-01') A
- join
- (select distinct r.member_id as mid,
- count(r.id) as rid
- from reservations r
- where r.state in ('completed','inUse')
- and Date(r.start_at + interval 8 hour) > '2019-01-01'
- group by 1) B
- on A.mid = B.mid
- group by 2
Advertisement
Add Comment
Please, Sign In to add comment