ahmedrahil786

Doc Reject - card approved - Rahil

Jun 10th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. set @start = '2020-01-01';
  2.  
  3. select
  4. (A.month) as month,
  5. count(A.mid) as Doc_rejected,
  6. count(B.mid) as Debit_Card_Approved,
  7. round((count(B.mid)/count(A.mid)*100),2) as PCT_Valid_DC_Doc_rejected
  8. from
  9. (select
  10. dl.member_id as mid,
  11. month(dl.created_at + interval '8' hour) as month
  12. from driver_licenses dl
  13. join members m
  14. on m.id = dl.member_id
  15. where dl.created_at + interval '8' hour >= @start
  16. and dl.state = 'reject'
  17. and m.imaginary = 'normal'
  18. group by 1) A
  19. left join
  20. (select
  21. pm.member_id as mid,
  22. month(pm.created_at + interval '8' hour) as month
  23. from
  24. payment_methods as pm
  25. where pm.created_at + interval '8' hour >= @start
  26. and pm.state = 'approved'
  27. group by 1) B
  28. on A.mid = B.mid
  29. group by 1
Advertisement
Add Comment
Please, Sign In to add comment