ahmedrahil786

Driving Licence Auto Vs manual Reject - Rahil

Dec 18th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. set @start := '2019-09-01 00:00';
  2. select
  3. Month(A.date) as date,
  4. count(distinct case when A.state not in ('noInput','null') then A.mid end) DocUploaded,
  5. count(distinct case when A.type in ('auto','any') and A.state = 'approved' then A.mid end) as Auto_Approved,
  6. count(distinct case when A.type in ('auto','any') and A.state = 'reject' then A.mid end) as Auto_reject,
  7. count(distinct case when A.type in ('manual') and A.state = 'approved' then A.mid end) as Manual_Approved,
  8. count(distinct case when A.type in ('manual') and A.state = 'reject' then A.mid end) as Manual_reject,
  9. (count(distinct case when A.type in ('auto','any') and A.state = 'reject' then A.mid end)/count(distinct case when A.type in ('auto','any') and A.state = 'approved' then A.mid end))*100 as PCT_AUTO_Approved_Reject,
  10. (count(distinct case when A.type in ('manual') and A.state = 'reject' then A.mid end)/count(distinct case when A.type in ('manual') and A.state = 'approved' then A.mid end)*100) as PCT_Manual_Approved_Reject
  11.  
  12. from
  13. (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
  14. from driver_licenses dl left join members m on m.id = dl.member_id
  15. where dl.created_at + Interval 8 hour >= @start
  16. and m.imaginary = 'normal'
  17. group by 1
  18. order by 1 desc) A
  19. group by 1 desc
Advertisement
Add Comment
Please, Sign In to add comment