SELECT
CASE WHEN
(SELECT * FROM table WHERE column = 'FY' AND person_id=74) --
<----- problem line
THEN 'OK'
ELSE
'BAD'
I think I figured out a way to do it, per
http://msdn.microsoft.com/en-us/library/ms181765.aspx
Maybe this will work:
CASE
SELECT COUNT(*) FROM table WHERE column = 'FY' AND person_id=74)
WHEN 0 THEN 'BAD'
ELSE 'OK'
There is not such thing as a CASE statement in SQL; there is a CASE
expression. Expressions return scalar values of one type. WHEN
clauses have to have search conditions. Is this what you meant?
SELECT
CASE WHEN
EXISTS (SELECT * FROM Foobar
WHERE some_column = 'FY'
AND person_id = 74)
THEN 'OK' ELSE 'BAD' END, ...
ok. understood.
> Expressions return scalar values of one type. WHEN
> clauses have to have search conditions. Is this what you meant?
>
> SELECT
> CASE WHEN
> EXISTS (SELECT * FROM Foobar
> WHERE some_column = 'FY'
> AND person_id = 74)
> THEN 'OK' ELSE 'BAD' END, ...
Yes, that will work. Thanks.