Quote:
Originally posted by odinsdream
I get an error with that method:
Syntax error converting varchar value 'x' to a column of data type tinyint.
Perhaps the problem is elsewhere? This is the full code: (you've seen it before ;-))
Code:
SELECT
MAX(CASE WHEN sd.ActiveSite = 1 THEN case WHEN sd.Forced IS NULL THEN 'x' ELSE sd.Forced END ELSE '' END),
...
...
Did I miss something? It seemed to me that this should have worked, too.
|
It appears that the parser has decided that the inner case statement should return a tinyint value - presumably because sd.Forced is a tinyint column? So the solution would be to convert sd.Forced to a character string - something like this:
case WHEN sd.Forced IS NULL THEN 'x' ELSE TO_CHAR(sd.Forced) END
I'm not sure if TO_CHAR is the right function name for your DBMS, but if not there must be an equivalent.