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
| SELECT C.matri,SUBSTRING (convert(varchar,C.dat,103),7,4) + SUBSTRING (convert(varchar,C.dat,103),4,2) + SUBSTRING (convert(varchar,C.dat,103),1,2) dat,C.hjtheo,C.hjpoin,F.hjcong,F.hjrtt,I.hjmalad,I.hjcredhe,COALESCE(L.hjabsaut,L.hjabsaut2)hjabsaut FROM
(SELECT COALESCE(A.EMPLOYEE_IDENTIFICATION_NUMBER,B.EMPLOYEE_IDENTIFICATION_NUMBER) matri,COALESCE(A.EMPLOYEE_SURNAME,B.EMPLOYEE_SURNAME) nom,A.hjpoin,B.hjtheo,COALESCE(A.TOTAL_DATE,B.TOTAL_DATE)dat FROM
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjpoin
FROM ESTIMATED_DAILY_TOTAL
WHERE TYPE_ABBREVIATION='eff')A
full JOIN
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjtheo
FROM ESTIMATED_DAILY_TOTAL
WHERE TYPE_ABBREVIATION='th')B
ON A.EMPLOYEE_IDENTIFICATION_NUMBER=B.EMPLOYEE_IDENTIFICATION_NUMBER AND A.TOTAL_DATE=B.TOTAL_DATE) C
full JOIN
(SELECT COALESCE(D.EMPLOYEE_IDENTIFICATION_NUMBER,E.EMPLOYEE_IDENTIFICATION_NUMBER) matri,COALESCE(D.EMPLOYEE_SURNAME,E.EMPLOYEE_SURNAME) nom,D.hjcong,E.hjrtt,COALESCE(D.TOTAL_DATE,E.TOTAL_DATE)dat FROM
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjcong
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION='CP')D
full JOIN
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjrtt
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION='RTT')E
ON D.EMPLOYEE_IDENTIFICATION_NUMBER=E.EMPLOYEE_IDENTIFICATION_NUMBER AND D.TOTAL_DATE=E.TOTAL_DATE) F
ON C.matri=F.matri AND C.dat=F.dat
full JOIN
(SELECT COALESCE(G.EMPLOYEE_IDENTIFICATION_NUMBER,H.EMPLOYEE_IDENTIFICATION_NUMBER) matri,COALESCE(G.EMPLOYEE_SURNAME,H.EMPLOYEE_SURNAME) nom,G.hjmalad,H.hjcredhe,COALESCE(G.TOTAL_DATE,H.TOTAL_DATE)dat FROM
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjmalad
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION='MAL')G
full JOIN
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjcredhe
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION='CH')H
ON G.EMPLOYEE_IDENTIFICATION_NUMBER=H.EMPLOYEE_IDENTIFICATION_NUMBER AND G.TOTAL_DATE=H.TOTAL_DATE)I
ON C.matri=I.matri AND C.dat=I.dat
full JOIN
(SELECT J.EMPLOYEE_IDENTIFICATION_NUMBER matri,J.EMPLOYEE_SURNAME nom,J.hjabsaut,K.hjabsaut2,J.TOTAL_DATE dat FROM
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjabsaut
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION IN ('PAT','DELEG','RCTp'))J
full join
(SELECT EMPLOYEE_IDENTIFICATION_NUMBER,EMPLOYEE_SURNAME,TOTAL_DATE,HOURS hjabsaut2
FROM ESTIMATED_DAILY_ABSENCE
WHERE ABS_TYPE_ABBREVIATION ='autre')K
ON J.EMPLOYEE_IDENTIFICATION_NUMBER=K.EMPLOYEE_IDENTIFICATION_NUMBER AND J.TOTAL_DATE=K.TOTAL_DATE)L
ON C.matri=L.matri AND C.dat=L.dat
where C.matri ='51011' AND C.dat >= '20121201' AND C.dat <= '20121220'
ORDER BY C.dat,C.matri |
Partager