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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-08-27 : 11:10:29
|
| mohan writes "Dear SQLGURU,How do I get the 'n'th largest value from a column of a single table without using Cursors? Mohan" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-27 : 13:05:50
|
| use top n with a subquery ordering descending then take the top 1 of that.If n is a variable use dynamic sql or put into a temp table using a set rowcount.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
arifktdm
Starting Member
6 Posts |
Posted - 2002-08-27 : 13:40:11
|
| declare @n intset @n=31)select a.x,(select count(distinct b.x) from rank b where b.x>=a.x) as [rank] from rank a2)select a.x from rank awhere @n=(select count(distinct b.x) from rank b where b.x>=a.x)Mohan, 1) gives rank for each value 2) is the script for ur requirement |
 |
|
|
|
|
|