Using case statement to evaluate 3 different conditions

  • Hi All

    I have a case statement which looks are 3 different columns to evaluate the expressions, the problem i am facing is tht as soon as it hits the first expression and that is true, it outputs the results and goes straight to End. This leaves out the other 2 expressions but i need the other 2 as the text needs to be Concatenated together.

    I can output the other 2 as seperate columns, but i need them all to be in one single column without outputing the other 2.

  • you didn't give any details, so here's an example that may help you.

    a case statement can evaluate more than one item:

    SELECT

    CASE

    WHEN Column1 = 'Approved' AND Column2 > (GETDATE() -14)

    THEN 'some status

    WHEN Column1 = 'Approved' AND Column2 <= (GETDATE() -14) AND MANAGMENTDELAY = 1

    THEN 'another status'

    ELSE 'Pending'

    END

    FROM SOMETABLE

    you could also have nested case statments so taht the THEN clause starts a whole separate CASE conditional testing. let us know if you need an example of that.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • thanks for the info, I have just sent you a PM.

    cheers

Viewing 3 posts - 1 through 2 (of 2 total)

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