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
| SELECT e.id, e.initiale, e.nom, e.prenom, e.j1, e.j2, e.j3, e.j4, e.j5, c.nbconge, c.nbcongeanc, c.nbcongereport,
coalesce(r.reportminutes, 0) as reportminutes,
case m.type when '6' then NbAbsence else 0 end as NbMaladie,
case m.type when '10' then NbAbsence else 0 end as NbCongePris,
coalesce(p.NbCongePris, 0) as NbCongePrisCeMois
FROM employer as e
LEFT JOIN
conge as c
ON c.id_employe = e.id
AND c.annee = '2017'
LEFT JOIN
( select l.initiale
, SUM(l.minutes) as reportminutes
FROM liste_hs as l
WHERE YEAR(date) = 2017
and MONTH(date) <= 9
GROUP BY l.initiale
) as r
ON r.initiale = e.Initiale
LEFT JOIN
( select t.initiale
, t.type
, COUNT(*) as NbAbsence
FROM pointage as t
WHERE t.initiale = e.Initiale
and t.type in ('6', '10')
and YEAR(datetimepointage) = 2017
and MONTH(datetimepointage) <= 9
GROUP BY t.initiale
, t.type
) as m
ON m.initiale = e.Initiale
LEFT JOIN
( select t.initiale
, COUNT(*) as NbCongePris
FROM pointage as t
WHERE t.initiale = e.Initiale
and t.type = '10'
and YEAR(datetimepointage) = 2017
and MONTH(datetimepointage) = 9
GROUP BY t.initiale
) as p
ON p.initiale = e.Initiale
WHERE type = '1'
GROUP BY nom, prenom
ORDER BY nom, prenom |
Partager