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

slightly different duplicate query 1

Status
Not open for further replies.

cdipaolo

Programmer
May 1, 2002
36
US
I have a table (PRICES) with the following data:
product, location, price, date. I want to find all of the records where the product and location are the same (shouldn't have more than one combination of product/location). I'm having trouble finding the right combination of count() and group() functions to whittle the list down. Does anyone have a similar query that they would share?

Thanks,

Chris
 
try (not tested):
Code:
Select product, location, Count(product) as Dups
from PRICES
Group By product, location
where Count(product) > 1;
should return the combinations that occur more than once.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thanks - you just need to change the "where" to "having" since count is an aggregate function. Exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top