I have this Oracle SQL request:
SELECT col1,
col2,
DECODE(
SUM(CASE WHEN col3='A' AND col4='+' THEN col5 ELSE 0 END),
NULL,
0,
SUM(CASE WHEN col3='A' AND col4='+' THEN col5 ELSE 0 END)
)
FROM mytable
group by col1, col2;
I am asking if there is a way to declare a kind of variable and have something like this:
SELECT col1,
col2,
DECODE(
myVariable,
NULL,
0,
myVariable
)
FROM mytable
group by col1, col2;