Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- count(distinct case when A.resv > 0 then A.mid end) as 1_res,
- count(distinct case when A.resv > 1 then A.mid end) as 2_res,
- count(distinct case when A.resv > 2 then A.mid end) as 3_res,
- count(distinct case when A.resv > 3 then A.mid end) as 4_res,
- count(distinct case when A.resv > 4 then A.mid end) as 5_res
- from
- (select
- distinct r.member_id as mid, count(r.id) as resv
- from reservations r left join members m on m.id = r.member_id
- where r.state = 'completed'
- and m.imaginary in ('sofam', 'normal')
- and r.member_id not in ('125', '127')
- group by 1) A
- where A.resv > 0
Advertisement
Add Comment
Please, Sign In to add comment