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
 General SQL Server Forums
 New to SQL Server Programming
 Max top 10 records

Author  Topic 

Divyanshu
Starting Member

2 Posts

Posted - 2011-08-03 : 03:24:25
I want to select top max(marks) 4 records from table
can anyone write the query in SQL server 2005
===========
Name marks
1 100
2 101
3 20
4 60
5 120
6 91
7 80

===========
output like
120
101
100
91



Dev

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-03 : 03:40:47
homework ?

take a look at http://msdn.microsoft.com/en-us/library/ms189463.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-08-03 : 05:04:14
Honestly its not difficult. Google 'TOP N'

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club
Go to Top of Page

Divyanshu
Starting Member

2 Posts

Posted - 2011-08-03 : 05:04:22
i got the solu..
select top 4 marks from table_name
order by extension desc



thanx khtan


Dev
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-03 : 05:50:44
quote:
Originally posted by Divyanshu

i got the solu..
select top 4 marks from table_name
order by extension desc



thanx khtan


Dev



why are you ORDER BY extension ?

shouldn't it be ORDER BY marks ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -