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!

List of customers that have NOT bought an item

Status
Not open for further replies.

wickyd

Technical User
Feb 14, 2002
57
ZA
Good day folx

I have a table called DEBTORS, which lists all the debtors by an account number (ACCOUNT - string) and name (NAME - string).

There are two tables which are used to track sales, STOCTRAN and STOCHIST. Both tables have identical structure. STOCTRAN is sales for the current month, and STOCHIST is sales from day one up to the last stock month end. The CODE column in these tables refers to the item that has been sold.

Table DEBTORS, column ACCOUNT = Table STOCHIST/STOCTRAN, column DEBTOR.

I want to generate a list of customers that have NOT bought a particular item. Therefore, the results from the STOCHIST/STOCTRAN query, which lists all the customers that have bought an item, must be "SUBTRACTED" from the list of debtors in the DEBTORS table and only the resultant debtors must be listed.

Any help would be greatly appreciated.
 
Code:
select d.* 
debtors as d left join stockhist as s
on d.account = s.debtor
where s.debtor is null
 
Hi swampBoogie

With a few mods here and there, your solution worked.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top