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 47 48 49 50 51 52 53 54 55 56
|
SELECT
TO_CHAR(cha.journee_postale,'DD/MM/YYYY') journee,
(
SUM(cha.ECOULEE)
+forfait( sar.ID_SAR1,sar.ID_ZA,cha.JOURNEE_POSTALE)
) charge_calculee,
FORCE_PRO(sar.ID_SAR1,cha.JOURNEE_POSTALE) FDP,
NVL(
(
(
SUM(cha.ECOULEE)
+
forfait( sar.ID_SAR1,sar.ID_ZA,cha.JOURNEE_POSTALE)
)
/( DECODE(
FORCE_PRO( sar.ID_SAR1, cha.JOURNEE_POSTALE ),
0,NULL,
FORCE_PRO( sar.ID_SAR1, cha.JOURNEE_POSTALE )
)
)
)
,0) taux_uti,
NVL(
(
(
forfait( sar.ID_SAR1,sar.ID_ZA,cha.JOURNEE_POSTALE)
)
/( DECODE(
(SUM(cha.ECOULEE))
,0,NULL,
(SUM(cha.ECOULEE))
)
)
)
,0) taux_forfait
FROM
SAR1 sar,
SAR2 sard,
SAR3 sart,
CHARGE cha
WHERE
sart.ID_CTC=PNI_ID_CTC
AND sart.ID_SAR3=sard.ID_SAR3
AND sard.ID_SAR2=sar.ID_SAR2
AND sar.ID_SAR1=cha.ID_SAR1
--validité de la journee postale ---------------------------------------------
AND TRUNC(PDI_DATE,'month')=TRUNC(cha.JOURNEE_POSTALE,'month')
AND sar.DATE_CREATION <=cha.JOURNEE_POSTALE
AND (sar.DATE_CREATION IS NULL OR sar.DATE_CREATION<=cha.JOURNEE_POSTALE)
AND sard.DATE_CREATION <=cha.JOURNEE_POSTALE
AND (sard.DATE_CREATION IS NULL OR sard.DATE_CREATION<=cha.JOURNEE_POSTALE)
AND sart.DATE_CREATION <=cha.JOURNEE_POSTALE
AND (sart.DATE_CREATION IS NULL OR sart.DATE_CREATION<=cha.JOURNEE_POSTALE)
AND cha.DATE_SUPPRESSION IS NULL
GROUP BY cha.journee_postale,sar.ID_SAR1,sar.ID_ZA; |
Partager