justuptime.com - monitor your servers & websites

sql question

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 87 posts

Joined: Dec 2001

I have a script that i need to find out the top posters.

I need to somehow find a way to select the highest amount of posts. Its really hard to explain, i have the table set up with a field called "dsub", i need to know how to select the most common user id in that field. If you know how to do this, please let me know.

http://www.newbie-developer.com - Newbie web-developer community.

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Try this:

SELECT TOP 5 dsub
FROM MyUserTable
GROUP BY dsub
ORDER BY COUNT(dsub) DESC

That will return the top 5 user ids. You'll have to modify it to work with your database tables and fields.

PJ | Are we there yet?
pjboettcher.com

Mark Hensler's picture

He has: 4,044 posts

Joined: Aug 2000

and for mySQL:

SELECT dsub
FROM MyUserTable
GROUP BY dsub
ORDER BY COUNT(dsub) DESC
LIMIT 5