Advertisement
psi_mmobile

Untitled

Jan 27th, 2023
1,503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.01 KB | None | 0 0
  1. SELECT first_date, last_date, work_code,TO_CHAR(first_date,'Day'),TO_CHAR(last_date,'Day'),'Sick',SUM(hrs) FROM (SELECT ptd.*  
  2. FROM   pd_trf_day  ptd, work_code wc, person p, vo_person_category vopc
  3. WHERE ptd.work_code_id = wc.work_code_id
  4. AND wc.work_code_std_category_id = 2
  5. AND ptd.person_id = p.person_id
  6. AND p.vo_person_category_id = vopc.vo_person_category_id
  7. AND (317219 IS NULL OR ptd.person_id = 317219)
  8. AND (101420 IS NULL OR vopc.vehicle_owner_id = 101420)
  9. AND (111928 IS NULL OR vopc.vo_person_category_id = 111928)
  10. AND (SYSDATE - 365 IS NULL OR ptd.date_day >= SYSDATE - 365)
  11. AND (SYSDATE IS NULL OR ptd.date_day <= SYSDATE)
  12. )
  13. match_recognize (
  14.   ORDER BY date_day
  15.   measures  
  16.     FIRST(date_day) AS first_date,
  17.     LAST(date_day) AS last_date,
  18.     NVL(trf_dhr,0) AS hrs,
  19.     COUNT(*) AS days,
  20.     work_code_id AS work_code,
  21.     match_number() AS grp
  22.   pattern ( strt consecutive* )
  23.   define  
  24.     consecutive AS date_day = ( prev ( date_day ) + 1 )
  25. )
  26. GROUP BY first_date,last_date,work_code;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement