Suppose I have the following.
select
case
when fcompany = \'Acme\' then \'Red\'
when fcompany = \'Acme Rockets\' then \'Blue\'
else \'Green\'
en
Try this:
SELECT b.Color,
sum(fann_sales)
FROM (
SELECT case
when fcompany = 'Acme' then 'Red'
when fcompany = 'Acme Rockets' then 'Blue'
else 'Green'
end
Color,
fann_sales
FROM slcdpm
) a RIGHT JOIN
(
SELECT 'Red' AS Color
UNION ALL
SELECT 'Blue' AS Color
UNION ALL
SELECT 'Green' AS Color
) b
ON a.Color = b.Color
GROUP BY b.Color