*-- On unit les 2 tables ( tp1 et tp2 ) SELECT nvl( tp2.cnomt , tp1.cnomt ) AS 'cnomt' ,; nvl( tp2.cnosecret ,tp1.cnosecret) AS 'cnosecret',; nvl( tp2.cparaphe , tp1.cparaphe) AS 'cparaphe',; nvl( tp2.iFoncId ,tp1.iFoncId) AS 'iFoncId' , ; nvl( tp2.yconso,tp1.yconso) AS 'yconso',; nvl( tp2.yconson,tp1.yconson) AS 'yconson',; nvl(tp2.netpsPlAs,tp1.netpsPlAs) AS 'netpsPlAs',; nvl( tp2.netpsPlNAs, tp1.netpsPlNAs) AS 'netpsPlNAs',; nvl( tp2.nextrAss,tp1.nextrAss) AS 'nextrAss' ,; nvl( tp2.nextrNass,tp1.nextrNass) AS 'nextrNass' ,; nvl( tp2.nOrdreF,tp1.nOrdreF) AS 'nOrdreF',; nvl( tp2.cnomf,tp1.cnomf) AS 'cnomf',; nvl( tp2.cPauseNo,tp1.cPauseNo) AS 'cPauseNo',; nvl( tp2.iemplId,tp1.iemplId) AS 'iemplId',; nvl( tp2.D01b ,'. ')AS 'D01b',; nvl( tp2.D02b ,'. ')AS 'D02b',; nvl( tp2.D03b ,'. ')AS 'D03b',; nvl( tp2.D04b ,'. ')AS 'D04b',; nvl( tp2.D05b ,'. ')AS 'D05b',; nvl( tp2.D06b ,'. ')AS 'D06b',; nvl( tp2.D07b ,'. ')AS 'D07b',; nvl( tp2.D08b ,'. ')AS 'D08b',; nvl( tp2.D09b ,'. ')AS 'D09b',; nvl( tp2.D10b ,'. ')AS 'D010b',; nvl( tp2.D11b ,'. ')AS 'D011b',; nvl( tp2.D12b ,'. ')AS 'D012b',; nvl( tp2.D13b ,'. ')AS 'D013b',; nvl( tp2.D14b ,'. ')AS 'D014b',; nvl( tp2.D15b ,'. ')AS 'D015b',; nvl( tp2.D16b ,'. ')AS 'D016b',; nvl( tp2.D17b ,'. ')AS 'D017b',; nvl( tp2.D18b ,'. ')AS 'D018b',; nvl( tp2.D19b ,'. ')AS 'D019b',; nvl( tp2.D20b ,'. ')AS 'D020b',; nvl( tp2.D21b ,'. ')AS 'D021b',; nvl( tp2.D22b ,'. ')AS 'D022b',; nvl( tp2.D23b ,'. ')AS 'D023b',; nvl( tp2.D24b ,'. ')AS 'D024b',; nvl( tp2.D25b ,'. ')AS 'D025b',; nvl( tp2.D26b ,'. ')AS 'D026b',; nvl( tp2.D27b ,'. ')AS 'D027b',; nvl( tp2.D28b ,'. ')AS 'D028b',; nvl( tp2.D29b ,'. ')AS 'D029b',; nvl( tp2.D30b ,'. ')AS 'D030b',; nvl( tp2.D31b ,'. ')AS 'D031b',; nvl( tp1.D01 ,'. ')AS 'D01',; nvl( tp1.D02 ,'. ')AS 'D02',; nvl( tp1.D03 ,'. ')AS 'D03',; nvl( tp1.D04 ,'. ')AS 'D04',; nvl( tp1.D05 ,'. ')AS 'D05',; nvl( tp1.D06 ,'. ')AS 'D06',; nvl( tp1.D07 ,'. ')AS 'D07',; nvl( tp1.D08 ,'. ')AS 'D08',; nvl( tp1.D09 ,'. ')AS 'D09',; nvl( tp1.D10 ,'. ')AS 'D010',; nvl( tp1.D11 ,'. ')AS 'D011',; nvl( tp1.D12 ,'. ')AS 'D012',; nvl( tp1.D13 ,'. ')AS 'D013',; nvl( tp1.D14 ,'. ')AS 'D014',; nvl( tp1.D15 ,'. ')AS 'D015',; nvl( tp1.D16 ,'. ')AS 'D016',; nvl( tp1.D17 ,'. ')AS 'D017',; nvl( tp1.D18 ,'. ')AS 'D018',; nvl( tp1.D19 ,'. ')AS 'D019',; nvl( tp1.D20 ,'. ')AS 'D020',; nvl( tp1.D21 ,'. ')AS 'D021',; nvl( tp1.D22 ,'. ')AS 'D022',; nvl( tp1.D23 ,'. ')AS 'D023',; nvl( tp1.D24 ,'. ')AS 'D024',; nvl( tp1.D25 ,'. ')AS 'D025',; nvl( tp1.D26 ,'. ')AS 'D026',; nvl( tp1.D27 ,'. ')AS 'D027',; nvl( tp1.D28 ,'. ')AS 'D028',; nvl( tp1.D29 ,'. ')AS 'D029',; nvl( tp1.D30 ,'. ')AS 'D030',; nvl( tp1.D31 ,'. ')AS 'D031',; x.TOTAL; FROM tp2 FULL JOIN tp1 ON tp2.iemplId = tp1.iemplId ,; ( SELECT iemployeeid ,; COUNT(*) TOTAL; FROM Horaire WHERE ddate BETWEEN D_debut AND d_fin AND ; ( ( cpauseid # 0 AND cpauseid2 # 0 ) OR cpauseid # 0 OR cpauseid2 # 0 ) GROUP BY 1 ) x ; WHERE nvl( tp1.iemplId , tp2.iemplId ) = x.iemployeeid INTO CURSOR Tp>>sorry !
>select Employee.cName; >, X.Total; >FROM FORCE (SELECT iemployeeid ; >, COUNT(*) Total; > from horaire WHERE cpauseid#0 OR cpauseid2#0 GROUP BY 1) X ; > join Employee on Employee.iid=X.iemployeeid; > ORDER BY 1 >