0

I want to assign a Yes or No to a column based on if another variable is Blank or not.

Would it be something like this?

if OpenedDate is Empty then

set Opened = No

if OpenedDate is NotEmpty then

set Opened = Yes

0

You need to use a CASE statement in order to accomplish this. So something like:

CASE WHEN OpenedDate IS NULL THEN 'No' ELSE 'Yes' END AS 'Opened'
  • Says there is an error near the 'AS". – JFH May 20 at 15:15
  • Case When o.EventDate is Null THEN 'No' ELSE 'Yes' AS 'Open', – JFH May 20 at 15:19
  • The above is missing 'END'. Just tested this statement and it resolves just fine on my end. – Jason Hanshaw May 20 at 15:19
  • Haha. I also just added it and it worked. – JFH May 20 at 15:27
  • Case When o.EventDate is Null THEN 'No' ELSE 'Yes' END AS 'Open' , – JFH May 20 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.