Rank() with Null at the end

I am using MS SQL Server 2005. I have a query where I am using the Rank() command. Something like this...

SELECT RANK() OVER (PARTITION BY GameID ORDER BY PlayTime ASC) AS GRank FROM GameScore

Problem is the NULL values in the column get the higher rank. I want NULLs to be ranked at the end. I have seen some ORACLE SQL examples, but apparently either I have got this wrong or MS SQL Server treats the Rank() command differently than ORACLE!!
LVL 9
Shahid ThaikaSole ProprietorAsked:
Who is Participating?
 
brad2575Commented:
This should work, but you may need to replace with something else depending on the value/data type of "PlayTime".

SELECT RANK() OVER (PARTITION BY GameID ORDER BY ISNULL(PlayTime, '12/31/2079' ASC) AS GRank FROM GameScore

0
 
Shahid ThaikaSole ProprietorAuthor Commented:
Awesome! That did the trick!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.