Advertisement
psi_mmobile

Untitled

Sep 14th, 2021
1,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.17 KB | None | 0 0
  1. WITH hr AS
  2.   (SELECT pd.person_id,
  3.     pd.date_day,
  4.     pd.is_locked,
  5.     SUM(CASE WHEN wc.work_code_std_id = 110 THEN pd.TRF_DHR ELSE 0 END) HR_DAY,
  6.     SUM(CASE WHEN wc.work_code_std_id = 114 THEN pd.TRF_DHR ELSE 0 END) HR_NIGHT,
  7.     wc.short_code,
  8.     pd.ref_number,
  9.     listagg (pd.user_comment, '/' ) user_comment
  10.   FROM pd_trf_day pd,
  11.     pd_day pdd,
  12.     work_code wc
  13.   WHERE pd.person_id                = pdd.person_id
  14.   AND pd.date_day                   = pdd.date_day
  15.   AND pd.work_code_id               = wc.work_code_id
  16.   AND pd.TRF_DHR > 0
  17.   AND wc.work_code_std_id IN (110,114)
  18.   GROUP BY pd.person_id,
  19.     pd.date_day,
  20.     pd.is_locked,
  21.     wc.short_code,
  22.     pd.ref_number)
  23.   SELECT hr.person_id,
  24.   hr.date_day,
  25.   hr.is_locked,
  26.   hr.ref_number,
  27.   p.company_nr,
  28.   p.last_name,
  29.   p.first_name,
  30.   q.name,
  31.   TO_CHAR(hr.date_day,'dd/MM/yyyy') DATE_STR,
  32.   hr.hr_day,
  33.   hr.hr_night,
  34.   hr.user_comment
  35.   FROM hr, person p, vo_person_category vopc,pd_day pdd, qualification q
  36.   WHERE hr.person_id = pdd.person_id
  37.   AND pdd.person_id = p.person_id
  38.   AND hr.date_day = pdd.date_day
  39.   AND p.master_qualification_id = q.qualification_id
  40.   ORDER BY 2,4,5,6,7;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement