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!

Top three numbers query

Status
Not open for further replies.

generaluser

Technical User
May 24, 2002
79
US
I have a field that list ages of people. I want to run a query that gives me the top three occuring ages and how many times they occur in that field. What would be the best way to do this?
Thanks in advance for the help
 
This SQL code

SELECT TOP 3 MyTblX.MyNum, Count(MyTblX.MyNum) AS CountOfMyNum
FROM MyTblX
GROUP BY MyTblX.MyNum
ORDER BY MyTblX.MyNum DESC;


Selects the Top three values in the field MyNum in the table MyTblX and displays the number of occurances of each in CountOfMyNum.
( Rename as required )

QED?

G LS
 
Thanks. Please check my other thread "Query based on multiple criteria". I definitely need help with that. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top