Reputation: 161
cast(sum(case
when x.product = 'APPLE' and x.colour ='RED'then round(x.price1,2)
when x.product <> 'APPLE' then **'NULL'**
ELSE 0
end) as decimal) as price,
price
column is of type decimal
. But I want to give an output as Null for only this second when statement instead of decimal value.
How can I do that?
Upvotes: 0
Views: 276
Reputation: 678
Have simple NULL. It should work as below.
select cast(sum(case
when x.product = 'Apple' and x.colour ='RED'then round(x.price,2)
when x.product <> 'Apple' then NULL
ELSE 0
end) as decimal) as price
Upvotes: 1