Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with select statement.

Status
Not open for further replies.

cb49747

MIS
Apr 23, 2002
181
US
I'm not sure how to do this and was hoping for some help here.

I have a transaction table, wich has multiple transactions for one customer. each transaction has type. I want to find all customers who do not have a particular type of transaction.

The problem I have is it seems to find a postive result for every customer because every customer has a least one transaction that is not of this type. and I want the ones who have never had a transaction of this type.

Not sure if that makes sense.

anyway, appreciate any help.
 
This query lists all of the customers with transactions of the particular type.
Code:
SELECT DISTINCT customer_id
FROM Transactions
WHERE Transactions.type = 'particular type'

So the ones you are looking for are not in that list.
Code:
SELECT * FROM Customers
WHERE customer_id NOT IN (
    SELECT DISTINCT customer_id
    FROM Transactions
    WHERE Transactions.type = 'particular type'
   )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top