4 |
andreas |
1 |
-- Datum von: ???, Bis: ???
|
|
|
2 |
-- Mitarbeiter: Theofilu Andreas (1)
|
|
|
3 |
select ta_name, sum(al_hours), ta_num, ta_start, ta_duration, ta_hash
|
|
|
4 |
from task right join plan on pl_num = ta_plnum and pl_status in (2,3,4,5) and
|
|
|
5 |
pl_prnum = 90001
|
|
|
6 |
left join allocation on al_task = ta_num and al_ressource = 1
|
|
|
7 |
where ta_num in (
|
|
|
8 |
select ta_num from task where
|
|
|
9 |
ta_meeting = 0 and ta_level > 1 and
|
|
|
10 |
(ta_start between 1145491200 and 1146009600 or
|
|
|
11 |
ta_start+ta_duration*86400 between 1138752000 and 1146355200 or
|
|
|
12 |
1145491200 between ta_start and ta_start+ta_duration*86400 or
|
|
|
13 |
1146009600 between ta_start and ta_start+ta_duration*86400
|
|
|
14 |
or ta_num in (
|
|
|
15 |
select distinct wd_task from wdone where
|
|
|
16 |
wd_minum = 1 and wd_prnum = 90001 and
|
|
|
17 |
wd_datum between 1145491200 and 1146009600
|
|
|
18 |
order by wd_task desc)
|
|
|
19 |
) order by pl_num desc)
|
|
|
20 |
group by ta_num, ta_hash, ta_start, ta_duration, ta_name order by ta_num desc;
|
|
|
21 |
|
|
|
22 |
-- Alle Tasks die bebuchbar sind bzw. auf denen IST-Buchungen vorhanden sind
|
|
|
23 |
select distinct on(ta_num) ta_name, ta_num, ta_start, ta_duration, ta_hash
|
|
|
24 |
from task, allocation
|
|
|
25 |
where al_task = ta_num and al_ressource = 1 and
|
|
|
26 |
ta_meeting = 0 and ta_level > 1 and
|
|
|
27 |
(ta_plnum = 66 or ta_plnum in (
|
|
|
28 |
select distinct pl_num from wdone, plan, task where
|
|
|
29 |
ta_num = wd_task and pl_num = ta_plnum and
|
|
|
30 |
wd_prnum = 90001 and wd_minum = 1 and
|
|
|
31 |
wd_datum between 1145491200 and 1146009600 and
|
|
|
32 |
pl_status in (2,3,4,5) order by pl_num desc)) and
|
|
|
33 |
(ta_start between 1145491200 and 1146009600 or
|
|
|
34 |
ta_start+ta_duration*86400 between 1145491200 and 1146009600 or
|
|
|
35 |
1145491200 between ta_start and ta_start+ta_duration*86400 or
|
|
|
36 |
1146009600 between ta_start and ta_start+ta_duration*86400)
|
|
|
37 |
order by ta_num desc;
|
|
|
38 |
|
|
|
39 |
select * from temptask order by tmp_num;
|
|
|
40 |
drop table temptask;
|