Case heirarchy

  • Curious, is there a way to set up a hierarchy in SQL. Here's what I'm looking to do.

    If an OCC code = 08 then NCP.Expected

    But, if the person doesn't have an OCC code of 08 but instead has a 0...I'd then what the NCP.Expected.

    So, I'd want it to check for 08 first and give the Expected field and if they don't have an 08 check for 0 and give the Expected field.

  • Like this? Your question is somewhat confusing and incomplete.

    CASE

    WHEN OOC_Code = '08' THEN SomeValue

    WHEN OOC_Code = '0' THEN SomeValue

    ELSE DefaultValue

    END

    Brad Feaker"Tantum religio potuit suadere malorum." - Lucretius
  • That's what I figured....but on one of my records it's still showing the Expected for the 0 OCC code...hmmmm

  • Post your SQL statement here, preferably with a sample of the data you have been using.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

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

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