August 19, 2020 at 4:55 pm
I need help with my where clause. The criteria below works except source_ID '100' keeps showing up in my data. Basically I have 2 OR's and 1 AND. What is the best way to use these together? Im sure I must be doing this incorrectly.
FROM table1
WHERE (APPLE_IND = 1 OR GRAPES_IND = 1)
AND SOURCE_ID <> 100 OR ADDRESS <> 'NOT APPLICABLE'
August 19, 2020 at 5:04 pm
Maybe this?
FROM table1
WHERE (APPLE_IND = 1 OR GRAPES_IND = 1)
OR (SOURCE_ID <> 100 AND ADDRESS <> 'NOT APPLICABLE')
If not, can you try putting your requirement into English?
"Choose rows where either (this) or (this and this) is true"
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
August 19, 2020 at 6:42 pm
Or maybe you need this?!:
...
AND SOURCE_ID <> 100 AND ADDRESS <> 'NOT APPLICABLE'
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply