Top X

CJBIRKIN

Drink!
Local time
Today, 12:28
Joined
May 10, 2002
Messages
255
Hello

I would like to do a top 5 query on a groupby query the trouble is i get the top 5 names i.e in alphabetical order rather than the top 5 highest values from the count

SELECT TOP 5 Count(TBL_ADHOC_REQUESTS.[REQUESTER ID]) AS [TOP 5 REQUESTERS], TBL_REQUESTERS.Names
FROM TBL_REQUESTERS RIGHT JOIN TBL_ADHOC_REQUESTS ON TBL_REQUESTERS.ID = TBL_ADHOC_REQUESTS.[REQUESTER ID]
GROUP BY TBL_REQUESTERS.Names;

Any ideas?

Chris
 
Hello solved it

SELECT TOP 5 Count(TBL_ADHOC_REQUESTS.[REQUEST ID]) AS [TOP 5 REQUESTERS], TBL_REQUESTERS.Names
FROM TBL_REQUESTERS RIGHT JOIN TBL_ADHOC_REQUESTS ON TBL_REQUESTERS.ID = TBL_ADHOC_REQUESTS.[REQUESTER ID]
GROUP BY TBL_REQUESTERS.Names
ORDER BY Count(TBL_ADHOC_REQUESTS.[REQUEST ID]) DESC;

DOH!
 

Users who are viewing this thread

Back
Top Bottom