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
| SELECT TO_CHAR(SG_MOVEMENT1.POSTDATE,'IW') AS SEMAINE,
SG_MOVEMENT1.PRODUCTIONLINE AS WORKCENTER,
SG_MOVEMENT1.MACHINE AS MACHINE,
TEXT_TRANSLATION.MEDIUM AS MOTIF,
SUM(SG_MOVEMENT1.QUANTITY) AS REBUTS,
ROUND(SUM(SG_MOVEMENT1.QUANTITY) * 100/TOT.SOMMEREBUTS,2) AS POURCENTAGE
FROM USR560.SG_MOVEMENT SG_MOVEMENT1,
USR560.REASON_CODE REASON_CODE,
USR560.TEXT_TRANSLATION TEXT_TRANSLATION,
(SELECT TO_CHAR(SG_MOVEMENT.POSTDATE,'IW') AS SEMAINE,
SG_MOVEMENT.PRODUCTIONLINE,
SG_MOVEMENT.MACHINE,
SUM(SG_MOVEMENT.QUANTITY) AS SOMMEREBUTS
FROM USR560.SG_MOVEMENT
WHERE SG_MOVEMENT.TRANSACTIONCODE IN (N'0')
AND SG_MOVEMENT.STATUS IN (N'1')
GROUP BY TO_CHAR(SG_MOVEMENT.POSTDATE,'IW'),
SG_MOVEMENT.PRODUCTIONLINE,
SG_MOVEMENT.MACHINE
) TOT
WHERE TEXT_TRANSLATION.LANGUAGEID IN (N'1033')
AND SG_MOVEMENT1.REASONCODE = REASON_CODE.REASONCODE
AND REASON_CODE.TEXTID = TEXT_TRANSLATION.TEXTID
AND SG_MOVEMENT1.TRANSACTIONCODE IN (N'0')
AND SG_MOVEMENT1.STATUS IN (N'1')
AND TOT.SEMAINE = TO_CHAR(SG_MOVEMENT1.POSTDATE,'IW')
AND TOT.PRODUCTIONLINE = SG_MOVEMENT1.PRODUCTIONLINE
AND TOT.MACHINE = SG_MOVEMENT1.MACHINE
AND SG_MOVEMENT1.POSTDATE BETWEEN TO_DATE('05/01/2009 00:00','DD/MM/YYYY HH24:MI') AND TO_DATE('31/12/2009 23:59','DD/MM/YYYY HH24:MI')
GROUP BY TO_CHAR(SG_MOVEMENT1.POSTDATE,'IW'),
SG_MOVEMENT1.PRODUCTIONLINE,
SG_MOVEMENT1.MACHINE,
TEXT_TRANSLATION.MEDIUM,
TOT.SOMMEREBUTS |
Partager