I need help writing a case statement to represent. The base table has 2 columns that I will refer to: "Stage" and "YesNo".
If the Stage column is 1 and the YesNo column is 1, I need a CASE statement to show it in the view as No. If the Stage column is 1 and the YesNo column is 0, I need a CASE statement to show it in the view as βYesβ. If the Stage column is 1 and the YesNo column is NULL, I need a CASE statement to show it in the view as NULL. If Stage has a value other than 1, I need the YesNo column to display as NULL in the view.
This is my logic so far, I think it is correct, but when I try to start it, I get a syntax error regarding the word "AS". Any suggestions?
CASE WHEN a.Stage = 1 and a.YesorNo = 1 THEN 'No' ELSE WHEN a.Stage = 1 and a.YesorNo = 0 THEN 'Yes' END AS NewViewColumn
source share