Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @start := '2019-1-1 00:00';
- select
- D.date,
- D.TotalMFTs
- from (select date(c.created_at + interval '8' hour) as date, count(distinct case when c.kind = 'subscriptionFee' then c.member_id end) as TotalMFTs from charges c
- join members m on m.id = c.member_id
- where c.created_at + interval '8' hour >= @start and m.imaginary = 'normal'
- group by 1) D
- group by 1
- order by 1 asc;
- select
- A.month, A.AM, B.signups
- from
- (select
- month(r.occupy_start_at + interval '8' hour) as month,
- count(distinct case when r.state = 'completed' then r.member_id end) as AM
- from reservations r
- where r.start_at + interval '8' hour >= @start
- and r.state = 'completed'
- group by 1) A
- left join
- (select
- month(m.created_at + interval '8' hour) as month, count(distinct m.id) as signups from members m
- where m.created_at + interval '8' hour >= @start and m.imaginary = 'normal'
- group by 1 ) B
- on A.month = B.month
- group by 1
Advertisement
Add Comment
Please, Sign In to add comment