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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Customers NOT buying items

Status
Not open for further replies.

wadjssd

Technical User
Jan 24, 2002
31
0
0
GB
Hi all,

Hopefully there's a more simple way to do what I'm trying here - via some funky SQL code.

I have an item that is my best-selling line. I have created a table(A) containing all the people that have bought it in the last month, and another table(B) containing all of the other items that all of these people have bought, sorted by descending popularity (based on total sales).

I need to identify, for each customer in table A, the top 5 items in table B that they haven't already bought.

I was thinking of doing a cross-join on table A to a list of distinct items from B, then outer joining the result on buyer and item to identify the nulls (and therefore the non-existent buyer/item combinations), but it's clunky and my cross join will be potentially enormous.

Many thanks
wadjssd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top