Selecting records and true or false value

  • SIJCOOKE

    SSC Enthusiast

    Points: 156

    Hi All,

    Thanks in advanced for help given. I have the following table:

    1<b></b><i></i><u></u>

    I want to run a query to show two columns - process ID and a Boolean column. The Boolean column will be true if all the completeddatetime values have a datestamp for that process id. It will be false if any of the completeddatetime values have a null.

    So the output should say:

    5931  true

    5932  true

    5933  false

    5934  false

    I have tried this with iif statement and case statement but cant get it working, but am sure its quite simple!

    Thank you. sijcooke

     

  • Jeff Moden

    SSC Guru

    Points: 994917

    This is a duplicate post and it's actually incomplete.  Please, no replies here.  See the following post instead.  It's also been answered but don't let that stop you if you have a better way to solve this problem.

    https://www.sqlservercentral.com/forums/topic/selecting-records-and-true-or-false-value

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

    Helpful Links:
    How to post code problems
    Create a Tally Function (fnTally)

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

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