Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Selecting the top 5

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2002-07-08 : 20:51:07
I have a table where it tracks how many times a person logs into there page. What would be the code to retrive the top 5 people that log in? The coulmn name is "logins" and that table name is "activity" Does anyone know how to do this in either T-SQL or ASP?

--
For thouse with wings, fly to your dreams.

Edited by - Eagle_f90 on 07/08/2002 20:51:42

joshb
Yak Posting Veteran

52 Posts

Posted - 2002-07-08 : 21:27:15
SELECT TOP 5 COUNT(*), logins
FROM activity
GROUP BY logins
ORDER BY COUNT(*) DESC

Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2002-07-08 : 21:52:08
Thanks alot. That did the trick.

--
For thouse with wings, fly to your dreams.
Go to Top of Page
   

- Advertisement -