I want to do a case on the result of 2 columns. How do I do this?
e.g.:
SELECT CASE amount=100 AND DATE IS NOT NULL WHEN 0 THEN 'Something' ELSE ''
Something like that?
I want to do a case on the result of 2 columns. How do I do this?
e.g.:
SELECT CASE amount=100 AND DATE IS NOT NULL WHEN 0 THEN 'Something' ELSE ''
Something like that?
select case
when amount = 100 and date is not null then 'something'
else 'something else'
end
This is a "searched case expression" (see MSDN):
CASE
WHEN Boolean_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ] END
select someColumnName,
case
when amount = 100 AND someothercondition then 'XXX'
when amount = 1000 AND anothercondition then 'YYY'
else 'WWW'
end as "MyColumnName"
from myTable
select case when amount = 100 and date is not null then '0' else 'something else' end