Monday, March 19, 2012

Help Needed With Simple Case Statement in SQL

Hello,

I am looking to modify this Case Statement. Where it says ELSE '' I need it to display the actual contents of the cell. 1 = Yes , 0 = No, (any other integer) = actual value.

Right now if the value is anything other than 1 or 0, it will leave the cell blank.

CASE dbo.Training.TrainingStatus WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END AS TrainingStatus

Thank You.

Try something like this:

CASE dbo.Training.TrainingStatus WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE CAST(dbo.Training.TrainingStatus AS varchar(20)) END AS TrainingStatus

No comments:

Post a Comment