ahmedrahil786

Revisit - Normal MFTs

Jul 31st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. select A.date, A.mid, B.rid from
  2.  
  3. (select
  4. distinct c.member_id as mid,
  5. Date(c.created_at + interval 8 hour) as date
  6. from charges c left join members m on m.id = c.member_id
  7. where c.kind = 'subscriptionFee'
  8. and Date(c.created_at + interval 8 hour) > '2019-01-01') A
  9. join
  10. (select distinct r.member_id as mid,
  11. count(r.id) as rid
  12. from reservations r
  13. where r.state in ('completed','inUse')
  14. and Date(r.start_at + interval 8 hour) > '2019-01-01'
  15. group by 1) B
  16. on A.mid = B.mid
  17. group by 2
Advertisement
Add Comment
Please, Sign In to add comment