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)
 query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-03-29 : 06:33:45
joy writes "i have 50 records in A TABLE.each record contains name and run .
KINDLY LET US KNOW THE SQL STATEMENT SO THAT WE CAN FIND OUT FIRSE 5 RECORDS THOSE WHO ARE SCORE MORE RUNS."

ijprasad
Starting Member

29 Posts

Posted - 2005-03-29 : 07:46:38
SELECT TOP 5 * FROM [TABLENAME] ORDER BY RUNS DESC

Inderjeet
Go to Top of Page

andy8979
Starting Member

36 Posts

Posted - 2005-03-29 : 07:54:25

use the following query


Select top 5 name, sum(run) as runs
from table
group by name
order by sum(runs)

Go to Top of Page
   

- Advertisement -