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

1 Answer 1

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'
5
  • Says there is an error near the 'AS".
    – JFH
    May 20, 2019 at 15:15
  • Case When o.EventDate is Null THEN 'No' ELSE 'Yes' AS 'Open',
    – JFH
    May 20, 2019 at 15:19
  • The above is missing 'END'. Just tested this statement and it resolves just fine on my end. May 20, 2019 at 15:19
  • Haha. I also just added it and it worked.
    – JFH
    May 20, 2019 at 15:27
  • Case When o.EventDate is Null THEN 'No' ELSE 'Yes' END AS 'Open' ,
    – JFH
    May 20, 2019 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .