1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| WITH t AS (SELECT 'AVT1' avt, 1 INDX, '&' logic_code, 9 code FROM dual
UNION ALL SELECT 'AVT2' avt, 1 INDX, '&' logic_code, 10 code FROM dual
UNION ALL SELECT 'AVT3' avt, 1 INDX, '&' logic_code, 11 code FROM dual
UNION ALL SELECT 'AVT1' avt, 2 INDX, '&' logic_code, 12 code FROM dual
UNION ALL SELECT 'AVT2' avt, 2 INDX, '&' logic_code, 13 code FROM dual
UNION ALL SELECT 'AVT2' avt, 3 INDX, '|' logic_code, 14 code FROM dual)
SELECT avt,
MAX(DECODE(code, 9, 1, 0)) I9, NVL(MAX(DECODE(code, 9, logic_code, '')),'0') LO1,
MAX(DECODE(code, 10, 1, 0)) I10, NVL(MAX(DECODE(code, 10, logic_code, '')),'0') LO2,
MAX(DECODE(code, 11, 1, 0)) I11, NVL(MAX(DECODE(code, 11, logic_code, '')),'0') LO3,
MAX(DECODE(code, 12, 1, 0)) I12, NVL(MAX(DECODE(code, 12, logic_code, '')),'0') LO4,
MAX(DECODE(code, 13, 1, 0)) I13, NVL(MAX(DECODE(code, 13, logic_code, '')),'0') LO5,
MAX(DECODE(code, 14, 1, 0)) I14, NVL(MAX(DECODE(code, 14, logic_code, '')),'0') LO6
FROM t
GROUP BY avt |
Partager