Converting an Nested IIf statement to a CASE statement

  • Hello all, I'm looking to convert the following IIf statement to a CASE statement. I didn't see anything in the forums that might give me some direction. If there is a post with guidance would you point me in the right direction.

    ((IIf([StudentStatus] <> "Active", IIf([EnrollmentLDA] Is Null, "N", ""), "") )<>"N")

    Thank you much,

    Z

  • Did you post the entire expression? The inequality test at the end does not seem to fit.

    Anyway, here's an example you could try:

    case

    when[StudentStatus] <> 'Active'

    then

    case

    when[EnrollmentLDA] Is Null

    then'N'

    else''

    else''

    end

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Matija, thanks for the response. No, the entire expression was not posted just this snippet. I was looking for a way to convert this to a CASE statement. I tried a couple of different ways but no luck. Think I just needed another set of eyes on it.

    Thanks again,

    Z

  • So, does it work as expected? 😉

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Not sure. I'll test and post back in a few days.

    Cheers,

    Z

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply