By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
SELECT CASE WHEN sum(unadj_gross_for_other_brand+adjustments_for_other_brand) = 0 AND
sum(adjustments_for_other_brand+redist_gross) = 0 THEN 0 ELSE 1 END status,
'Unadjusted Other='||sum(unadj_gross_for_other_brand)||
' Adjustments Other='||sum(adjustments_for_other_brand)||
' Adjusted Other='||sum(unadj_gross_for_other_brand+adjustments_for_other_brand) ||
' Redistributed='||sum(redist_gross) Note
FROM
(
select
1 as unadj_gross_for_other_brand,
0 as adjustments_for_other_brand,
0 as redist_gross
from dual
UNION
select
0 as unadj_gross_for_other_brand,
2 as adjustments_for_other_brand,
0 as redist_gross
from dual
UNION
select
0 as unadj_gross_for_other_brand,
0 as adjustments_for_other_brand,
3 as redist_gross
from dual
);
STATUS | NOTE |
---|---|
1 | Unadjusted Other=1 Adjustments Other=2 Adjusted Other=3 Redistributed=3 |
SELECT CASE WHEN sum(unadj_gross_for_other_brand+adjustments_for_other_brand) = 0 AND
sum(adjustments_for_other_brand+redist_gross) = 0 THEN 0 ELSE 1 END status,
'Unadjusted Other='||sum(unadj_gross_for_other_brand)||
' Adjustments Other='||sum(adjustments_for_other_brand)||
' Adjusted Other='||sum(unadj_gross_for_other_brand+adjustments_for_other_brand) ||
' Redistributed='||sum(redist_gross) Note
FROM
(
select
0 as unadj_gross_for_other_brand,
0 as adjustments_for_other_brand,
0 as redist_gross
from dual
);
STATUS | NOTE |
---|---|
0 | Unadjusted Other=0 Adjustments Other=0 Adjusted Other=0 Redistributed=0 |
SELECT CASE WHEN sum(unadj_gross_for_other_brand+adjustments_for_other_brand) = 0 AND
sum(adjustments_for_other_brand+redist_gross) = 0 THEN 0 ELSE 1 END status,
'Unadjusted Other='||sum(unadj_gross_for_other_brand)||
' Adjustments Other='||sum(adjustments_for_other_brand)||
' Adjusted Other='||sum(unadj_gross_for_other_brand+adjustments_for_other_brand) ||
' Redistributed='||sum(redist_gross) Note
FROM
(
select
1 as unadj_gross_for_other_brand,
-1 as adjustments_for_other_brand,
0 as redist_gross
from dual
UNION
select
0 as unadj_gross_for_other_brand,
0 as adjustments_for_other_brand,
1 as redist_gross
from dual
);
STATUS | NOTE |
---|---|
0 | Unadjusted Other=1 Adjustments Other=-1 Adjusted Other=0 Redistributed=1 |