need help fast!

  • Thread starter Thread starter sn0w0wl
  • Start date Start date
S

sn0w0wl

I've been pulling my hair out trying to figure out how to make this query...

I need to make a list of repeat customers...there's 10 customers total and
only 2 are repeat...

how do I get the query to show only the repeat customers?
 
You mean you want to know which customers show up in the list more than
once?

You can use a query like:

SELECT CustomerID
FROM MyTable
GROUP BY CustomerID
HAVING Count(*) > 1

To get the details for those customers, you can use that as a subquery
against your Customer table:

SELECT CustomerID, CustomerName, CustomerAddress, ...
FROM Customer
WHERE CustomerID IN (SELECT CustomerID
FROM MyTable
GROUP BY CustomerID
HAVING Count(*) > 1)
 
OMG thank you soooo much....you're a life saver!

Douglas J. Steele said:
You mean you want to know which customers show up in the list more than
once?

You can use a query like:

SELECT CustomerID
FROM MyTable
GROUP BY CustomerID
HAVING Count(*) > 1

To get the details for those customers, you can use that as a subquery
against your Customer table:

SELECT CustomerID, CustomerName, CustomerAddress, ...
FROM Customer
WHERE CustomerID IN (SELECT CustomerID
FROM MyTable
GROUP BY CustomerID
HAVING Count(*) > 1)
 
Hi,
you can use the built in query "find duplicates"

Hope this help.
Regards
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top