Count records in query by most records

L

larpup

I need to create a query that will count the (3) most records (of same
value) in that query? The Example below should return Anaheim, Azusa
and Hollywood. Not Los Angeles and Burbank.

Anaheim
Anaheim
Anaheim
Anaheim
Anaheim
Los Angeles
Los Angeles
Los Angeles
Azusa
Azusa
Azusa
Azusa
Azusa
Azusa
Azusa
Azusa
Burbank
Hollywood
Hollywood
Hollywood
Hollywood
Hollywood
Hollywood

Any assistance is appreciated.

Lar
 
K

Ken Sheridan

Lar:

Try this:

SELECT DISTINCT Place
FROM Places
WHERE Place IN
(SELECT TOP 3 Place
FROM (SELECT Place,COUNT(*) AS PlaceCount
FROM Places
GROUP BY Place)
ORDER BY PlaceCount DESC);

Ken Sheridan
Stafford, England
 

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

Top