Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @start := '2019-01-01 00:00';
- select month(A.date) as month, Year(A.date) as year, count(A.mid) as total_Reject,
- count(distinct case when B.attempts >= '2' then B.mid end) as More_than_2_Attempts
- from
- #### Finding Rejected people at Doc Uploaded Stage
- (select distinct dl.member_id as mid, min(dl.id) as dlid, dl.approval_type as type, dl.state as state , Date(dl.created_at + interval 8 hour) as date
- from driver_licenses dl left join members m on m.id = dl.member_id
- where dl.created_at + Interval 8 hour >= @start
- and m.imaginary = 'normal'
- and dl.state = 'reject'
- group by 1
- order by 1 desc) A
- left join
- #### Finding attempts
- (select distinct dl.member_id as mid, count(dl.id) as attempts
- from driver_licenses dl left join members m on m.id = dl.member_id
- where dl.created_at + Interval 8 hour >= @start
- and m.imaginary = 'normal'
- and dl.state not in ('noInput','null')
- group by 1
- order by 2 desc) B
- on A.mid = B.mid
- group by 1,2
- order by 2 asc, 1 asc
Advertisement
Add Comment
Please, Sign In to add comment