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)
 My First One

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-12 : 07:28:42
Krishnakumar writes "How to get the row that has Nth Largest value for a column ?
Using Cursor is OK .But any other alternative is there?"

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-12-12 : 07:41:53
http://www.dotnetspider.com/technology/qa/ViewQuestion.aspx?QuestionId=1995
You will find out so many even in this forum.. just search

Surendra
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-12 : 07:48:20
Select min(col) from
(
Select Top N col from yourTable order by col DESC
) T

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-12-12 : 14:39:25
"Using Cursor is OK"

Oh no its not! [Pantomime season here in the UK!]

Variation on Maddy's code:

Select TOP 1 MyCol
from
(
Select Top N MyCol
from yourTable
order by col DESC
) T
order by col ASC

Kristen
Go to Top of Page
   

- Advertisement -