Advertisement
psi_mmobile

Untitled

Mar 15th, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. select ROW_NUMBER() over (partition by person_id, "Datum" order by "Uren","Minuten")
  2. from (
  3. SELECT pd.person_id,
  4. p.vo_person_category_id,
  5. pd.is_locked,
  6. vo.contact_msisdn as "Nummer werkgever",
  7. replace(p.company_nr,'HBB') as "Nummer werknemer",
  8. vo.company_name as "Naam werkgever",
  9. p.last_name || ' ' || p.first_name as "Naam werknemer",
  10. decode(wc.short_code,'P',decode(pdd.day_journey_role,'P','P','D ','CH','DA','CH','P'),wc.short_code) as "Looncode",
  11. decode(wc.work_code_std_category_id,1,p_wbs.getlvl0WbsRefNumber(w.wbs_id),2,'AFWEZIG') as "Werf",
  12. pd.date_day as "Datum",
  13. replace(to_char(extract (hour from numtodsinterval(sum(pd.TRF_DHR), 'HOUR' )),'00'),' ','') as "Uren",
  14. replace(to_char(extract (minute from numtodsinterval(sum(pd.TRF_DHR), 'HOUR' )),'00'),' ','') as "Minuten",
  15. -- case when wc.short_code = 'P' or wc.short_code = 'GWH' then sum(greatest(nvl(pdd.declared_vehicle_km,0))) else 0 end as "Gerapporteerde Km",
  16. -- case when wc.short_code = 'P' or wc.short_code = 'GWH' then sum(greatest(nvl(pdd.declared_private_km,0))) else 0 end as "Prive Km",
  17. case when wc.short_code = 'P' or wc.short_code = 'GWH' then nvl(sum(pdd.declared_vehicle_km),0) else 0 end as "Gerapporteerde Km",
  18. case when wc.short_code = 'P' or wc.short_code = 'GWH' then nvl(sum(pdd.declared_private_km),0) else 0 end "Prive Km",
  19. pd.pd_trf_user_comment as "Commentaar"
  20. FROM pd_trf_day pd,
  21. person p,
  22. pd_day pdd,
  23. work_code wc,
  24. wbs w,
  25. vo_person_category vopc,
  26. vehicle_owner vo
  27. WHERE pd.person_id = pdd.person_id
  28. AND pd.date_day = pdd.date_day
  29. AND pdd.person_id = p.person_id
  30. and p.vo_person_category_id = vopc.vo_person_category_id
  31. and vopc.vehicle_owner_id = vo.vehicle_owner_id
  32. AND pd.work_code_id = wc.work_code_id
  33. and wc.vehicle_owner_id = vo.vehicle_owner_id
  34. and pd.wbs_id = w.wbs_id(+)
  35. and wc.vehicle_owner_id = 101404
  36. and wc.work_code_std_category_id in (1,2)
  37. and nvl(pd.TRF_DHR,0) > 0
  38. and p.person_status_id = 0
  39. and p.person_Id = 220197
  40. and pd.date_day = to_date('21/09/2020 00:00','dd//mm/yyyy HH24:MI')
  41. group by pd.person_id,p.vo_person_category_id,pd.is_locked,pd.date_day,w.ref_number,p.company_nr,wc.short_code,vo.contact_msisdn,vo.company_name,p.last_name || ' ' || p.first_name,
  42. decode(wc.short_code,'P',decode(pdd.day_journey_role,'P','P','D ','CH','DA','CH','P'),wc.short_code),decode(wc.work_code_std_category_id,1,p_wbs.getlvl0WbsRefNumber(w.wbs_id),2,'AFWEZIG'),
  43. case when wc.short_code = 'P' or wc.short_code = 'GWH' then nvl(pdd.declared_vehicle_km,0) else 0 end,
  44. case when wc.short_code = 'P' or wc.short_code = 'GWH' then nvl(pdd.declared_private_km,0) else 0 end,
  45. pd.pd_trf_user_comment
  46. order by "Nummer werknemer",pd.date_day);
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement