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
| SELECT Total.cgde020
, SUM(Encours.montprop) AS SumEncours
, SUM(Accepte.montprop) AS SumAccepte
, SUM(Refuse.montprop) AS SumRefuse
, COUNT(Encours.cgde130) AS NbrEncours
, COUNT(Accepte.cgde130) AS NbrAccepte
, COUNT(Refuse.cgde130) AS NbrRefuse
, SUM(Total.montprop) AS SumTotal
, COUNT(Total.cgde130) AS NbrTotal
FROM TDE001 AS Total
LEFT JOIN TDE001 AS Encours
ON Total.cgde020 = Encours.cgde020
AND Total.cgde050 = Encours.cgde050
LEFT JOIN TDE001 AS Accepte
ON Total.cgde020 = Accepte.cgde020
AND Total.cgde050 = Accepte.cgde050
LEFT JOIN TDE001 AS Refuse
ON Total.cgde020 = Refuse.cgde020
AND Total.cgde050 = Refuse.cgde050
WHERE Encours.cgde130 = 0
AND Accepte.cgde130 = 1
AND Refuse.cgde130 = 2
AND Total.cgde050 = '30003'
GROUP BY Total.cgde020
, Total.cgde050
; |
Partager