SELECT GROUP_ID, SUM(MAN) AS SUM_MANUELL, SUM(MAS) AS SUM_MASCHINELL, SUM(BEE) AS SUM_BEENDET, SUM(ABG) AS SUM_ABGEBROCHEN, SUM(UMT) AS SUM_UMTYPISIERT, SUM(UMI) AS SUM_UMINDEXIERT FROM ( SELECT GV.GROUP_ID AS GROUP_ID, CASE WHEN GV.STAT_KZ = 1 AND (GV.INITIATOR = 2 OR GV.INITIATOR = 8 OR GV.INITIATOR = 9) THEN 1 ELSE 0 END AS MAN, CASE WHEN GV.STAT_KZ = 1 AND GV.INITIATOR <> 2 AND GV.INITIATOR <> 8 AND GV.INITIATOR <> 9 THEN 0 ELSE 1 END AS MAS, CASE WHEN GV.STAT_KZ = 7 THEN 1 ELSE 0 END AS BEE, CASE WHEN GV.STAT_KZ = 3 THEN 1 ELSE 0 END AS ABG, CASE WHEN GV.STAT_KZ = 5 THEN 1 ELSE 0 END AS UMI, CASE WHEN GV.STAT_KZ = 4 THEN 1 ELSE 0 END AS UMT FROM TDMS269 AS GV WHERE DATE(GV.STAT_TS) BETWEEN '2006-03-04' AND '2006-06-30' AND GV.GROUP_ID IN (SELECT USER_ID FROM TDMS239 WHERE GROUP_ID = 'OG01193') ) T22 GROUP BY GROUP_ID FOR FETCH ONLY WITH UR ;
Comments 39
SUM(MAN) AS SUM_MANUELL,
SUM(MAS) AS SUM_MASCHINELL,
SUM(BEE) AS SUM_BEENDET,
SUM(ABG) AS SUM_ABGEBROCHEN,
SUM(UMT) AS SUM_UMTYPISIERT,
SUM(UMI) AS SUM_UMINDEXIERT
FROM (
SELECT GV.GROUP_ID AS GROUP_ID,
CASE WHEN GV.STAT_KZ = 1 AND (GV.INITIATOR = 2 OR GV.INITIATOR = 8 OR GV.INITIATOR = 9) THEN 1 ELSE 0 END AS MAN,
CASE WHEN GV.STAT_KZ = 1 AND GV.INITIATOR <> 2 AND GV.INITIATOR <> 8 AND GV.INITIATOR <> 9 THEN 0 ELSE 1 END AS MAS,
CASE WHEN GV.STAT_KZ = 7 THEN 1 ELSE 0 END AS BEE,
CASE WHEN GV.STAT_KZ = 3 THEN 1 ELSE 0 END AS ABG,
CASE WHEN GV.STAT_KZ = 5 THEN 1 ELSE 0 END AS UMI,
CASE WHEN GV.STAT_KZ = 4 THEN 1 ELSE 0 END AS UMT
FROM TDMS269 AS GV
WHERE
DATE(GV.STAT_TS) BETWEEN '2006-03-04' AND '2006-06-30'
AND GV.GROUP_ID IN (SELECT USER_ID FROM TDMS239 WHERE GROUP_ID = 'OG01193')
) T22
GROUP BY GROUP_ID
FOR FETCH ONLY WITH UR ;
Reply
Reply
Reply
Reply
Reply
Reply
Толкай
Reply
Reply
Reply
Reply
Reply
(The comment has been removed)
Reply
Leave a comment