Filter

  • Hey guys, i created a TSQL script which produced the result set described below.

    Pre-Status      Current-Status

    yes                        no

    null                         yes

    null                          null

     

    question is how can i filter to prevent rows where both Pre-Status and Current-Status = null?

    thx in advance

  • Add to you where condition

    AND ([Pre-Status] IS NOT NULL AND [Current-Status] IS NOT NULL)

  • didn't work

    it's dropping other rows

    here's an example of my where clause

    where

    Patient_Current_Pregnancy_details

    .Gestational_Age_weeks >= '36'and

    (

    Patient_Current_Pregnancy_details.C13_Test_Result = 'Pos' or Patient_Current_Pregnancy_details.C13_Test_Result is null)

    and

    (Patient_Previous_C13_Test.Test_Result <> 'Neg' or Patient_Previous_C13_Test.Test_Result is null )

    --and (Patient_Current_Pregnancy_details.C13_Test_Result is not null and Patient_Previous_C13_Test.Test_Result is not null)

  • Sorry I meant OR not AND. Try this

    WHERE

    Patient_Current_Pregnancy_details.Gestational_Age_weeks >= '36'

    and IsNull(Patient_Current_Pregnancy_details.C13_Test_Result,'Pos') = 'Pos'

    and IsNull(Patient_Previous_C13_Test.Test_Result,'Neg') != 'Neg'

    and (

     Patient_Current_Pregnancy_details.C13_Test_Result is not null OR

     Patient_Previous_C13_Test.Test_Result is not null

    )

    In the above either can be null but OR says both cannot be.

  • thx man

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

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