Thread: Excluding Rows
View Single Post
  #1 (permalink)  
Old August 17th, 2005, 11:55 AM
fs22 fs22 is offline
Friend of Wrox
 
Join Date: Apr 2004
Location: Wausau, WI, USA.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excluding Rows

I have an orders table that contains customer product orders. It has a model number field and a customer number field. Here is an example of the table...

[u]Customer Number Model Number</u>
123 aaa
123 bbb
124 aaa
124 bbb
125 aaa
125 bbb
125 ccc

What I would like to do is get a query that excludes customers that have ordered a specific model number. FOr example, if I want to see customers that have ordered products excepp for model number 'ccc', I want it to pull the following info...

[u]Customer Number</u>
123
124

In my SQL statement, it is pulling the following...

[u]Customer Number</u>
123
124
125

What it is doing is excluding the model number 'ccc', but still includes the customer 125 because they have ordered other products. Does any have any thoughts on how to do this correctly?

Note that the above are simply examples of the tables. If you would like to see my actual SQL statement, here it is...

SELECT DISTINCT CUSTOMERNUMBER
FROM tbl_orders
WHERE ProductModelNumber <> 'H5160R'

Thanks in advance

Clay Hess
__________________
Clay Hess
Reply With Quote