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
| SELECT T1.NUMERO_SIRET_CABINET, T1.NBDOSSIERS, T2.NBVGE
FROM (
SELECT NUMERO_SIRET_CABINET,COUNT(*) AS NBDOSSIERS
FROM DOSSIERS.FIC
WHERE ((DATE_RAPPORT_1A='20090610') OR (DATE_RAPPORT_1A='' AND DATE_RAPPORT_1B='20090610'))
GROUP BY NUMERO_SIRET_CABINET
) T1
FULL OUTER JOIN
(
SELECT T3.NUMERO_SIRET_CABINET, COUNT(*) AS NBVGE
FROM (
SELECT DISTINCT f1.ID_DOSSIER, f1.NUMERO_SIRET_CABINET
FROM DOSSIERS.FIC AS f1
LEFT OUTER JOIN DANGEROSITE_DOSSIER.FIC AS f2 ON f1.ID_DOSSIER = f2.ID_DOSSIER
WHERE CODE_DANGEROSITE IN('CA3', 'LS3', 'DI3', 'SP4')
AND CODE_GENRE IN('TAGE03', 'TAGE16', 'TAGE30')
AND CODE_NATURE_EVENEMENT IN('TANE11', 'TANE12')
AND (
(DATE_RAPPORT_1A = '20090611' AND DANGEROSITE_1A = '1')
OR (DATE_RAPPORT_1A='' AND DATE_RAPPORT_1B = '20090611' AND DANGEROSITE_1B = '1')
)
AND REPARABILITE_ECONOMIQUE = '1'
) T3
GROUP BY T3.NUMERO_SIRET_CABINET
) T2
ON T1.NUMERO_SIRET_CABINET=T2.NUMERO_SIRET_CABINET; |
Partager