Grouping AND OR Logic

  • I am trying to use this logic

    ((1 OR 2) OR 6 OR 7 OR 8))  AND 3 AND 4 AND 5

    I tried this but, it is not retuning the right count

    select count(*)
    from "mytable"
    where
    ((Column1 ='Yes' OR Column2 ='Yes')
    OR
    (Column6='Yes' OR Column7='Yes' OR Column8='Yes')) 
    AND
    Column3 = 'Customer'
    AND
    Column4 ='US'
    AND
    Column5='Dead'
  • ((1 OR 2) OR (6 OR 7 OR 8))  AND 3 AND 4 AND 5

    Is exactly the same as:

    (1 OR 2 OR 6 OR 7 OR 8)  AND 3 AND 4 AND 5

    Did you actually want:

    (1 OR 2) AND (6 OR 7 OR 8)  AND 3 AND 4 AND 5

    ?

  • Thanks @sscoach

    These pesky And/Ors. They always confuse me

    Yes, what I actually want is (1 OR 2) AND (6 OR 7 OR 8)  AND 3 AND 4 AND 5

     

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

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