1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
|
SELECT project,
CASE
WHEN INSTR(tasks, ',', 1, 1) = 0 THEN tasks
ELSE SUBSTR(tasks, 1, INSTR(tasks, ',', 1, 1) - 1)
END
taskl1,
CASE
WHEN INSTR(tasks, ',', 1, 1) = 0
THEN
NULL
WHEN INSTR(tasks, ',', 1, 2) = 0
THEN
SUBSTR(tasks, INSTR(tasks, ',', 1, 1) + 1)
ELSE
SUBSTR(
tasks,
INSTR(tasks, ',', 1, 1) + 1,
INSTR(tasks, ',', 1, 2) - INSTR(tasks, ',', 1, 1) - 1
)
END
taskl2,
CASE
WHEN INSTR(tasks, ',', 1, 2) = 0
THEN
NULL
WHEN INSTR(tasks, ',', 1, 3) = 0
THEN
SUBSTR(tasks, INSTR(tasks, ',', 1, 2) + 1)
ELSE
SUBSTR(
tasks,
INSTR(tasks, ',', 1, 2) + 1,
INSTR(tasks, ',', 1, 3) - INSTR(tasks, ',', 1, 2) - 1
)
END
taskl3,
CASE
WHEN INSTR(tasks, ',', 1, 3) = 0
THEN
NULL
WHEN INSTR(tasks, ',', 1, 4) = 0
THEN
SUBSTR(tasks, INSTR(tasks, ',', 1, 3) + 1)
ELSE
SUBSTR(
tasks,
INSTR(tasks, ',', 1, 3) + 1,
INSTR(tasks, ',', 1, 4) - INSTR(tasks, ',', 1, 3) - 1
)
END
taskl4,
CASE
WHEN INSTR(tasks, ',', 1, 4) = 0 THEN NULL
ELSE SUBSTR(tasks, INSTR(tasks, ',', 1, 4) + 1)
END
taskl5,
CASE
WHEN INSTR(actuals, ',', 1, 1) = 0 THEN TO_NUMBER(actuals)
ELSE TO_NUMBER(SUBSTR(actuals, 1, INSTR(actuals, ',', 1, 1) - 1))
END
+ CASE
WHEN INSTR(actuals, ',', 1, 1) = 0
THEN
0
WHEN INSTR(actuals, ',', 1, 2) = 0
THEN
TO_NUMBER(SUBSTR(actuals, INSTR(actuals, ',', 1, 1) + 1))
ELSE
TO_NUMBER(SUBSTR(
actuals,
INSTR(actuals, ',', 1, 1) + 1,
INSTR(actuals, ',', 1, 2) - INSTR(actuals, ',', 1, 1) - 1
))
END
+ CASE
WHEN INSTR(actuals, ',', 1, 2) = 0
THEN
0
WHEN INSTR(actuals, ',', 1, 3) = 0
THEN
TO_NUMBER(SUBSTR(actuals, INSTR(actuals, ',', 1, 2) + 1))
ELSE
TO_NUMBER(SUBSTR(
actuals,
INSTR(actuals, ',', 1, 2) + 1,
INSTR(actuals, ',', 1, 3) - INSTR(actuals, ',', 1, 2) - 1
))
END
+ CASE
WHEN INSTR(actuals, ',', 1, 3) = 0
THEN
0
WHEN INSTR(actuals, ',', 1, 4) = 0
THEN
TO_NUMBER(SUBSTR(actuals, INSTR(actuals, ',', 1, 3) + 1))
ELSE
TO_NUMBER(SUBSTR(
actuals,
INSTR(actuals, ',', 1, 3) + 1,
INSTR(actuals, ',', 1, 4) - INSTR(actuals, ',', 1, 3) - 1
))
END
+ CASE
WHEN INSTR(actuals, ',', 1, 4) = 0 THEN 0
ELSE TO_NUMBER(SUBSTR(actuals, INSTR(actuals, ',', 1, 4) + 1))
END
actual
FROM ( SELECT LPAD(LEVEL, LEVEL * 3),
t.project,
t.tname,
s.actual,
LTRIM(SYS_CONNECT_BY_PATH(t.tname, ','), ',') tasks,
RTRIM(LTRIM(SYS_CONNECT_BY_PATH(s.actual, ','), ','), ',') actuals,
CONNECT_BY_ISLEAF isleaf
FROM task t, timesheet s
WHERE t.tname = s.task(+)
CONNECT BY t.parent = PRIOR t.tid AND LEVEL <= 5
START WITH parent = -1)
WHERE isleaf = 1
|