Advertisement
psi_mmobile

Untitled

May 7th, 2024
1,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.10 KB | None | 0 0
  1. SELECT p.person_id, w.wbs_id,w.name,TRUNC(md.date_day) date_day, p.company_nr, mtsl.hrd, mtsl.validation_status_id, x.sum_hrd FROM mw_time_sheet mts, mw_time_sheet_line mtsl, mfc_mobile_worker mmw, person p, fc_assignment fa, wbs w, mw_day md,
  2. (SELECT SUM(m.hrd) sum_hrd,m.mfc_mobile_worker_id, TRUNC(md.date_day) date_Day FROM mw_time_sheet_line m, mw_day md GROUP BY m.mfc_mobile_worker_id, TRUNC(md.date_day)) x
  3. WHERE mts.mw_time_sheet_id = mtsl.mw_time_sheet_id
  4. AND mtsl.mfc_mobile_worker_id = mmw.mfc_mobile_worker_id
  5. AND mmw.mfc_mobile_worker_id = x.mfc_mobile_worker_id
  6. AND mmw.erp_id = p.person_id
  7. AND p.vo_person_category_id = 102503
  8. AND mtsl.mw_day_id = md.mw_day_id
  9. AND md.date_day = x.date_day
  10. AND x.date_day >= TO_DATE('01/02/2024','DD/MM/YYYY')
  11. AND mtsl.validation_status_id = 48
  12. AND mtsl.fc_assignment_id = fa.fc_assignment_id
  13. --and fa.erp_id = w.wbs_id
  14. AND x.sum_hrd > (SELECT SUM(trf_dhr) FROM pd_trf_day ptd
  15. WHERE TRUNC(ptd.date_day) = TRUNC(md.date_day) --join with mw day
  16. AND ptd.person_id = p.person_id
  17. --and ptd.wbs_id = w.wbs_id
  18. GROUP BY ptd.person_id,TRUNC(ptd.date_day))
  19. ORDER BY 1,4;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement