ahmedrahil786

DV Team Efficiency - Rahil for Linda

Mar 30th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. set @startdate1 = '2020-03-01';
  2. set @startdate2 = '2020-03-31';
  3. use socar_malaysia;
  4. select A.DL_created_date as DL_created_date,
  5. Count(Distinct A.mid) as total_members,
  6. count(distinct case when A.Timediff_in_hours <= '3' then A.mid end) as "Less Than 3 hours",
  7. count(distinct case when A.Timediff_in_hours > '3' then A.mid end) as "More Than 3 hours",
  8. ROUND((count(distinct case when A.Timediff_in_hours <= '3' then A.mid end)/Count(Distinct A.mid))*100,2) as "less than 3 hours efficiency %",
  9. Round((count(distinct case when A.Timediff_in_hours > '3' then A.mid end)/Count(Distinct A.mid))*100,2) as "More than 3 hours efficiency %"
  10. from
  11. (select
  12. dl.member_id as mid,
  13. min(id) as id,
  14. dl.state as state,
  15. dl.created_at + interval 8 hour as dl_created_at_time,
  16. date(dl.created_at + interval 8 hour) as DL_created_date,
  17. (dl.updated_at + interval 8 hour) as dl_updated_hour,
  18. ROUND(TIMESTAMPDIFF(minute,dl.created_at + interval 8 hour,dl.updated_at + interval 8 hour)/60,2) as Timediff_in_hours
  19. from driver_licenses dl
  20. where dl.created_at + interval '8' hour >= @startdate1
  21. and dl.created_at + interval '8' hour <= @startdate2
  22. and dl.state in ('approved','reject')
  23. group by 1
  24. order by 1 desc) A
  25. Group by 1
  26. order by 1 desc
Advertisement
Add Comment
Please, Sign In to add comment