SELECT TO_CHAR(COUNT(*)) || ' salarié(s) actifs' as Col1,
       (SELECT TO_CHAR(COUNT(*))
        FROM T_PAI, T_SAL
             INNER JOIN T_HST_INFOSSOCIETE ON T_HST_INFOSSOCIETE.NumSalarie=T_SAL.SA_CompteurNumero AND T_HST_INFOSSOCIETE.InfoEnCours=1
        WHERE extract(MONTH FROM T_HST_INFOSSOCIETE.DateEmbauche) = T_PAI.MoisEnCours
              and extract(YEAR FROM T_HST_INFOSSOCIETE.DateEmbauche) = T_PAI.AnneeEnCours )
 || ' entrée(s) / ' ||
       (SELECT TO_CHAR(COUNT(*))
        FROM T_PAI,T_SAL
             INNER JOIN T_HST_INFOSSOCIETE ON T_HST_INFOSSOCIETE.NumSalarie=T_SAL.SA_CompteurNumero AND T_HST_INFOSSOCIETE.InfoEnCours=1
        WHERE extract(MONTH FROM T_HST_INFOSSOCIETE.DateDepart) = T_PAI.MoisEnCours
              and extract(YEAR FROM T_HST_INFOSSOCIETE.DateDepart) = T_PAI.AnneeEnCours )
|| ' sortie(s) / ' ||
        (SELECT TO_CHAR(COUNT(*))
        FROM T_SAL
             INNER JOIN T_HST_ETABLISSEMENT ON T_HST_ETABLISSEMENT.NumSalarie=T_SAL.SA_CompteurNumero AND T_HST_ETABLISSEMENT.InfoEnCours=1
        WHERE (T_SAL.EtatPaie IN (1, 2)) AND (NVL(T_HST_ETABLISSEMENT.MiseEnSommeil,0) = 1))
|| ' en sommeil' as Col2
FROM T_PAI,
     T_SAL
     INNER JOIN T_HST_ETABLISSEMENT ON T_HST_ETABLISSEMENT.NumSalarie=T_SAL.SA_CompteurNumero AND T_HST_ETABLISSEMENT.InfoEnCours=1
WHERE (NOT T_SAL.EtatPaie IN (0, 5, 7)) AND (NVL(T_HST_ETABLISSEMENT.MiseEnSommeil,0) <> 1)
GROUP BY T_PAI.IdPai
UNION
SELECT 'Bulletins  édités : ' || TO_CHAR(COUNT(*)) as Col1,
       '  ' as Col2
FROM T_SAL WHERE T_SAL.EtatPaie = 3
UNION
SELECT 'Bulletins à préparer : ' || TO_CHAR(COUNT(*)) as Col1,
        '  ' as Col2
FROM T_SAL
     INNER JOIN T_HST_ETABLISSEMENT ON T_HST_ETABLISSEMENT.NumSalarie=T_SAL.SA_CompteurNumero AND T_HST_ETABLISSEMENT.InfoEnCours=1
WHERE (T_SAL.EtatPaie IN (1, 2)) AND (NVL(T_HST_ETABLISSEMENT.MiseEnSommeil,0) <> 1)

