all groups > sql server data mining > april 2004 >
You're in the

sql server data mining

group:

iif statement in SELECT



iif statement in SELECT Diana
4/19/2004 11:01:04 AM
sql server data mining: I have 5 fields:

Name SpendAmount RecommendedAmount AmountOver Compliant
Jo 5000 3000 2000 Yes
Donna 2000 4000 0 No


I want to be able to generate the output in [Compliant] with an iif or CASE statements but either way I keep getting this error: Incorrect syntax near '>' in this part of my SELECT Statement.

iif(SpendAmount > RecommendedAmount, 'Yes', 'No') as Compliant

What am doing it wrong?

Thank you for your input and help.


Re: iif statement in SELECT Adam Machanic
4/19/2004 2:15:19 PM
Diana,

SQL has no IIF syntax; try the following CASE statement:

CASE
WHEN SpendAmount > RecommendedAmount THEN 'Yes'
ELSE 'No'
END as Compliant



[quoted text, click to view]
CASE statements but either way I keep getting this error: Incorrect
syntax near '>' in this part of my SELECT Statement.
[quoted text, click to view]

Re: iif statement in SELECT Dean
4/19/2004 2:18:11 PM
There is no iff statement in T-SQL. You need to use the CASE statement

[quoted text, click to view]
CASE statements but either way I keep getting this error: Incorrect
syntax near '>' in this part of my SELECT Statement.
[quoted text, click to view]

AddThis Social Bookmark Button