ahmedrahil786

DL second attempt check

Jun 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. set @start := '2019-01-01 00:00';
  3. select month(A.date) as month, Year(A.date) as year, count(A.mid) as total_Reject,
  4. count(distinct case when B.attempts >= '2' then B.mid end) as More_than_2_Attempts
  5. from
  6. #### Finding Rejected people at Doc Uploaded Stage
  7. (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
  8. from driver_licenses dl left join members m on m.id = dl.member_id
  9. where dl.created_at + Interval 8 hour >= @start
  10. and m.imaginary = 'normal'
  11. and dl.state = 'reject'
  12. group by 1
  13. order by 1 desc) A
  14. left join
  15. #### Finding attempts
  16. (select distinct dl.member_id as mid, count(dl.id) as attempts
  17. from driver_licenses dl left join members m on m.id = dl.member_id
  18. where dl.created_at + Interval 8 hour >= @start
  19. and m.imaginary = 'normal'
  20. and dl.state not in ('noInput','null')
  21. group by 1
  22. order by 2 desc) B
  23. on A.mid = B.mid
  24. group by 1,2
  25. order by 2 asc, 1 asc
Advertisement
Add Comment
Please, Sign In to add comment