Advertisement
psi_mmobile

Untitled

Nov 16th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 3.05 KB | None | 0 0
  1. WITH d AS
  2.   (SELECT TO_DATE(TO_CHAR(TO_DATE('12/10/2018','dd/MM/YYYY'),'dd/MM/YYYY'),'dd/MM/YYYY') AS from_date,
  3.     TO_DATE(TO_CHAR(TO_DATE('12/10/2018','dd/MM/YYYY'),'dd/MM/YYYY'),'dd/MM/YYYY') AS TO_DATE
  4.   FROM dual
  5.   )
  6. SELECT
  7. w.WBS_ID,
  8. w.r,
  9. w.PARENT_WBS_ID,
  10. w.OPERATION_CENTER_ID,
  11. w.CAN_ASSIGN_TEAM,
  12. w.LVL,
  13. w.ref_number,
  14. w.WBS_NAME_LEVEL_1,
  15. w.WBS_REF_NUMBER_LEVEL_1,
  16. w.WBS_NAME_LEVEL_2,
  17. w.WBS_REF_NUMBER_LEVEL_2,
  18. w.WBS_NAME_LEVEL_3,
  19. w.WBS_REF_NUMBER_LEVEL_3,
  20. p.DISPLAY_FIRST_DAY,
  21. p.PERIOD,
  22. p.START_DATE,
  23. p.END_DATE,
  24. DECODE (p.PERIOD, 'M', TO_CHAR ( p.DISPLAY_FIRST_DAY, 'YYYYMM'), TO_CHAR ( p.DISPLAY_FIRST_DAY, 'YYYYMMWW')) AS date_order,
  25. p_wbs.sumHrDPerWBS(w.wbs_id, p.start_date, p.end_date) AS SUM_HRD
  26. FROM
  27.   (SELECT DISTINCT TRUNC( from_date + LEVEL -1, 'iw') display_first_day,
  28.     'W' AS period,
  29.     CASE
  30.       WHEN TRUNC( from_date + LEVEL -1, 'iw') < from_date
  31.       THEN from_date
  32.       ELSE TRUNC( from_date + LEVEL -1, 'iw')
  33.     END AS start_date,
  34.     CASE
  35.       WHEN TRUNC( from_date + LEVEL -1, 'iw') + 6 > TO_DATE
  36.       THEN TO_DATE
  37.       ELSE TRUNC( from_date + LEVEL -1, 'iw') + 6
  38.     END AS end_date
  39.   FROM d
  40.     CONNECT BY LEVEL <= TO_DATE - from_date
  41.   UNION
  42.   SELECT DISTINCT TRUNC( from_date + LEVEL -1, 'MM') display_first_day,
  43.     'M' AS period,
  44.     CASE
  45.       WHEN TRUNC( from_date + LEVEL -1, 'MM') < from_date
  46.       THEN from_date
  47.       ELSE TRUNC( from_date + LEVEL -1, 'MM')
  48.     END AS start_date,
  49.     CASE
  50.       WHEN LAST_DAY( from_date + LEVEL -1) > TO_DATE
  51.       THEN TO_DATE
  52.       ELSE LAST_DAY( from_date + LEVEL -1)
  53.     END AS end_date
  54.   FROM d
  55.     CONNECT BY LEVEL <= TO_DATE - from_date
  56.   ORDER BY period,
  57.     display_first_day
  58.   ) p
  59. JOIN
  60.   (SELECT
  61.     ROWNUM AS r,
  62.     CASE
  63.       WHEN LEVEL = 1
  64.       THEN wbs.name
  65.       ELSE '/'
  66.     END AS wbs_name_level_1,
  67.     CASE
  68.       WHEN LEVEL = 1
  69.       THEN wbs.ref_number
  70.       ELSE '/'
  71.     END AS wbs_ref_number_level_1,
  72.     CASE
  73.       WHEN LEVEL = 2
  74.       THEN wbs.name
  75.       ELSE '/'
  76.     END AS wbs_name_level_2,
  77.     CASE
  78.       WHEN LEVEL = 2
  79.       THEN wbs.ref_number
  80.       ELSE '/'
  81.     END AS wbs_ref_number_level_2,
  82.     CASE
  83.       WHEN LEVEL = 3
  84.       THEN wbs.name
  85.       ELSE '/'
  86.     END AS wbs_name_level_3,
  87.     CASE
  88.       WHEN LEVEL = 3
  89.       THEN wbs.ref_number
  90.       ELSE '/'
  91.     END AS wbs_ref_number_level_3,
  92.     wbs.wbs_id,
  93.     parent_wbs_Id,
  94.     wbs.ref_number,
  95.     wbs.operation_center_id ,
  96.     wbs.can_assign_team,
  97.     LEVEL AS LVL
  98.   FROM wbs
  99.   WHERE LEVEL            <=3
  100.   AND operation_center_id = 101888
  101.     START WITH wbs_id  = 205520
  102.     CONNECT BY parent_wbs_id = PRIOR wbs_id
  103.   ORDER SIBLINGS BY ref_number
  104.   ) w
  105. ON 1 = 1
  106. WHERE ('true' = 'true'
  107. AND p.period  = 'M'
  108. AND (( 'true' = 'true'
  109. AND w.lvl     = 1 )
  110. OR ( 'true'  = 'true'
  111. AND w.lvl     = 2 )
  112. OR ( 'true'  = 'true'
  113. AND w.lvl     = 3 ) ) )
  114. OR ( 'true'   = 'true'
  115. AND p.period  = 'W'
  116. AND (('false' = 'true'
  117. AND w.lvl     = 1 )
  118. OR ( 'false'  = 'true'
  119. AND w.lvl     = 2 )
  120. OR ( 'false'   = 'true'
  121. AND w.lvl     = 3 )))
  122. ORDER BY r, date_order;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement