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?
From stackoverflow
-
select case when amount = 100 and date is not null then 'something' else 'something else' endThis is a "searched case expression" (see MSDN):
CASE WHEN Boolean_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] ENDMitch Wheat : beat me by 2 seconds! -
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
-
Look for
SELECT WHEN
0 comments:
Post a Comment