1

I need use case condition in sql server, the datatype is money, the condition is money>= 100, here is my code:

 insert into table1 
(  Col1,
   Col2,
   Col3
) 

select 
 ColA,
 ColB,
 case ColC when ColC >=100 then 'Y' else 'N' end

I got an error: Incorrect syntax near '>'. How do I compare money in sql? Thanks for your help.

4

1 回答 1

4

Use

case when ColC >=100 then 'Y' else 'N' end

You are mingling the two forms of the CASE expression (searched and simple). You would only use CASE ColC ... when all the match expressions are to have an = comparison on them (and then don't specify the operator explicitly).

于 2012-06-26T20:57:46.267 回答