Created
December 19, 2013 10:15
-
-
Save KresimirKoncicNeuralab/8037090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Rn int; | |
DECLARE @RnStart int; | |
DECLARE @RnEnd int; | |
DECLARE @Increment int = 5; | |
DECLARE @PlayerId int = 10; | |
Select @Rn = tt.RowNo FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY PlayerScore desc) as RowNo from Players) tt WHERE tt.PlayerId = @PlayerId; | |
SET @RnStart = @Rn-@Increment; | |
SET @RnEnd = @Rn+@Increment; | |
Select t.RowNo, t.PlayerName, t.PlayerId , t.PlayerScore, t.PlayerTime from ( Select *, ROW_NUMBER() OVER (ORDER BY PlayerScore desc) as RowNo from Players ) t where t.RowNo between @RnStart AND @RnEnd; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment