1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
WITH PROJECTHISTORY AS (SELECT 1 AS PROJECT, 'a' AS PROJECTLEADER, TO_DATE('01.01.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
UNION ALL SELECT 1 AS PROJECT, 'b' AS PROJECTLEADER, TO_DATE('15.01.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
UNION ALL SELECT 1 AS PROJECT, 'a' AS PROJECTLEADER, TO_DATE('01.06.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
UNION ALL SELECT 2 AS PROJECT, 'c' AS PROJECTLEADER, TO_DATE('01.10.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
UNION ALL SELECT 3 AS PROJECT, 'c' AS PROJECTLEADER, TO_DATE('01.01.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
UNION ALL SELECT 3 AS PROJECT, 'a' AS PROJECTLEADER, TO_DATE('01.07.2011', 'DD.MM.RRRR') AS STARTDATE FROM dual
)
SELECT PROJECT, projectleader, startdate, lead(startdate-1, 1) OVER (PARTITION BY PROJECT ORDER BY startdate) AS enddate
FROM PROJECTHISTORY
PROJECT leader STARTDATE ENDDATE
1 a 01/01/2011 14/01/2011
1 b 15/01/2011 31/05/2011
1 a 01/06/2011
2 c 01/10/2011
3 c 01/01/2011 30/06/2011
3 a 01/07/2011 |
Partager