![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I have a need to setup a CASE statement in Sybase (Transact) SQL where one of my branches is like this: 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, perhttp://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' |
#3
| |||
| |||
|
|
On Oct 22, 12:05*pm, metaperl <scheme... (AT) gmail (DOT) com> wrote: Hello, I have a need to setup a CASE statement in Sybase (Transact) SQL where one of my branches is like this: 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, perhttp://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, ... |
![]() |
| Thread Tools | |
| Display Modes | |
| |