select row_number()Over(Order BY Value ) as RankNumber,userid from MyRankTable
How to get Nth value from the sql table?
Some time we need to get top 4th rank from the table or top 5th person in the table. For that the below query will help you to get result dynamically. Based on the parameter passing the result will display.
declare @Position int
set @Position=2
select RankNumber,userid
from (
select row_number()Over(Order BY Value ) as RankNumber,userid
from MyRankTable
) MyResult
where RankNumber
=@Position
No comments:
Post a Comment