Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH d AS
- (SELECT TO_DATE(TO_CHAR(TO_DATE('12/10/2018','dd/MM/YYYY'),'dd/MM/YYYY'),'dd/MM/YYYY') AS from_date,
- TO_DATE(TO_CHAR(TO_DATE('12/10/2018','dd/MM/YYYY'),'dd/MM/YYYY'),'dd/MM/YYYY') AS TO_DATE
- FROM dual
- )
- SELECT
- w.WBS_ID,
- w.r,
- w.PARENT_WBS_ID,
- w.OPERATION_CENTER_ID,
- w.CAN_ASSIGN_TEAM,
- w.LVL,
- w.ref_number,
- w.WBS_NAME_LEVEL_1,
- w.WBS_REF_NUMBER_LEVEL_1,
- w.WBS_NAME_LEVEL_2,
- w.WBS_REF_NUMBER_LEVEL_2,
- w.WBS_NAME_LEVEL_3,
- w.WBS_REF_NUMBER_LEVEL_3,
- p.DISPLAY_FIRST_DAY,
- p.PERIOD,
- p.START_DATE,
- p.END_DATE,
- DECODE (p.PERIOD, 'M', TO_CHAR ( p.DISPLAY_FIRST_DAY, 'YYYYMM'), TO_CHAR ( p.DISPLAY_FIRST_DAY, 'YYYYMMWW')) AS date_order,
- p_wbs.sumHrDPerWBS(w.wbs_id, p.start_date, p.end_date) AS SUM_HRD
- FROM
- (SELECT DISTINCT TRUNC( from_date + LEVEL -1, 'iw') display_first_day,
- 'W' AS period,
- CASE
- WHEN TRUNC( from_date + LEVEL -1, 'iw') < from_date
- THEN from_date
- ELSE TRUNC( from_date + LEVEL -1, 'iw')
- END AS start_date,
- CASE
- WHEN TRUNC( from_date + LEVEL -1, 'iw') + 6 > TO_DATE
- THEN TO_DATE
- ELSE TRUNC( from_date + LEVEL -1, 'iw') + 6
- END AS end_date
- FROM d
- CONNECT BY LEVEL <= TO_DATE - from_date
- UNION
- SELECT DISTINCT TRUNC( from_date + LEVEL -1, 'MM') display_first_day,
- 'M' AS period,
- CASE
- WHEN TRUNC( from_date + LEVEL -1, 'MM') < from_date
- THEN from_date
- ELSE TRUNC( from_date + LEVEL -1, 'MM')
- END AS start_date,
- CASE
- WHEN LAST_DAY( from_date + LEVEL -1) > TO_DATE
- THEN TO_DATE
- ELSE LAST_DAY( from_date + LEVEL -1)
- END AS end_date
- FROM d
- CONNECT BY LEVEL <= TO_DATE - from_date
- ORDER BY period,
- display_first_day
- ) p
- JOIN
- (SELECT
- ROWNUM AS r,
- CASE
- WHEN LEVEL = 1
- THEN wbs.name
- ELSE '/'
- END AS wbs_name_level_1,
- CASE
- WHEN LEVEL = 1
- THEN wbs.ref_number
- ELSE '/'
- END AS wbs_ref_number_level_1,
- CASE
- WHEN LEVEL = 2
- THEN wbs.name
- ELSE '/'
- END AS wbs_name_level_2,
- CASE
- WHEN LEVEL = 2
- THEN wbs.ref_number
- ELSE '/'
- END AS wbs_ref_number_level_2,
- CASE
- WHEN LEVEL = 3
- THEN wbs.name
- ELSE '/'
- END AS wbs_name_level_3,
- CASE
- WHEN LEVEL = 3
- THEN wbs.ref_number
- ELSE '/'
- END AS wbs_ref_number_level_3,
- wbs.wbs_id,
- parent_wbs_Id,
- wbs.ref_number,
- wbs.operation_center_id ,
- wbs.can_assign_team,
- LEVEL AS LVL
- FROM wbs
- WHERE LEVEL <=3
- AND operation_center_id = 101888
- START WITH wbs_id = 205520
- CONNECT BY parent_wbs_id = PRIOR wbs_id
- ORDER SIBLINGS BY ref_number
- ) w
- ON 1 = 1
- WHERE ('true' = 'true'
- AND p.period = 'M'
- AND (( 'true' = 'true'
- AND w.lvl = 1 )
- OR ( 'true' = 'true'
- AND w.lvl = 2 )
- OR ( 'true' = 'true'
- AND w.lvl = 3 ) ) )
- OR ( 'true' = 'true'
- AND p.period = 'W'
- AND (('false' = 'true'
- AND w.lvl = 1 )
- OR ( 'false' = 'true'
- AND w.lvl = 2 )
- OR ( 'false' = 'true'
- AND w.lvl = 3 )))
- ORDER BY r, date_order;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement