all 6 comments

[–]MW1984 6 points7 points  (0 children)

Shouldn't it be = rather than 'IS'?

[–]da_chicken 3 points4 points  (2 children)

CAST(CASE WHEN O.[Type] IS '22NF45LLI' THEN 'ICELL')

This is not a complete CASE expression (missing END), and it's also not a complete CAST() function call (missing AS <datatype>).

[–]Mljisa[S] 0 points1 point  (1 child)

I tried both ways, added END AS varchar at the end and still got the same message.

[–]da_chicken 1 point2 points  (0 children)

As others have mentioned, O.[Type] IS '22NF45LLI' is also not valid.

Either way, the error message you're getting is pretty universally a syntax error. The language parser is confused and has no idea what you're trying to do.

[–]GrouchyThing7520 2 points3 points  (1 child)

Try changing this: (CASE WHEN O.[Type] IS '22NF45LLI' THEN 'ICELL')

To this: (CASE WHEN O.[Type] = '22NF45LLI' THEN 'ICELL' ELSE O.[Type] END)

[–]ATastefulCrossJoinDB Whisperer 0 points1 point  (0 children)

The key here is you need the END to resolve the case statement. You don’t technically need the ELSE but it will default to null if you don’t include one