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
| with total as
(
select '001'Mat , 'jerome' Nom, 'eff' Type , 7 Hours, to_date('03/12/2012') jour from dual union
select '001' , 'jerome' , 'th' , 8 , to_date('03/12/2012') from dual union
select '002' , 'andree' , 'eff' , 6 , to_date('03/12/2012')from dual union
select '002' , 'andree' , 'th' , 8 , to_date('03/12/2012')from dual union
select '001' , 'jerome' , 'eff' , 8 , to_date('04/12/2012')from dual union
select '002' , 'andree' , 'eff' , 8 , to_date('04/12/2012')from dual union
select '002' , 'andree' , 'th' , 8 , to_date('05/12/2012')from dual),
absence as
(select '001' mat , 'jerome' nom , 'cp' type2 , 7 hours, to_date('04/12/2012') jour from dual union
select '002' mat , 'andree' nom , 'rtt' type2 , 6 hours, to_date('05/12/2012') jour from dual
)
select C.mat,C.nom,C.eff,C.th,F.cp,F.rtt,C.jour from
---------------------------------------------------------------------------------------------
(select nvl(A.mat,B.mat) mat,nvl(A.nom,B.nom) nom,A.eff,B.th,nvl(A.jour,B.jour)jour from
(select mat,nom,jour,hours eff
from total
where type='eff')A --A
full join
(select mat,nom,jour,hours th
from total
where type='th')B --B
on A.mat=B.mat and A.jour=B.jour) C--C
----------------------------------------------------------------------------------------------
---------
full join
--------
---------------------------------------------------------------------------------------------
(select nvl(D.mat,E.mat) mat,nvl(D.nom,E.nom) nom,D.cp,E.rtt,nvl(D.jour,E.jour)jour from
(select mat,nom,jour,hours cp
from absence
where type2='cp')D --D
full join
(select mat,nom,jour,hours rtt
from absence
where type2='rtt')E--E
on D.mat=E.mat and D.jour=E.jour) F --F
----------------------------------------------------------------------------------------------
on C.mat=F.mat and C.jour=F.jour
order by C.jour,C.mat |
Partager