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!

I need to find the most occurances

Status
Not open for further replies.

Bri123456

Programmer
Jan 3, 2002
30
CA
Hi I have a field and this field contains numbers. I want to find the number in these fields the occurs the most,

row1 12
row2 100
row3 12

I want to write a query to get the result of 12. Any help with this will be graetly appreciated
 
Im not sure on how to find the most, but you can find duplicates, and see which appears the most there.

In the query section, hit new > Find duplicates... that by far is the easiest way, then has it sort desc. this way the most reaccuring one it at the top.
 
Have you tried something like this ?
SELECT TOP 1 theField, Count(theField) AS Occurance
FROM theTable
GROUP BY theField
ORDER BY Count(theField) DESC;

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top