Data in the table
ID attempt1 attempt2 attempt3
1 2.00 2.10 1.99
2 2.15 2.01 1.80
3 1.85 2.05 1.98
Expected result
ID attempt1 attempt2 attempt3 rank
2 2.15 2.01 1.80 1
1 2.00 2.10 1.99 2
3 1.85 2.05 1.98 3
Query to achieve result
select ID, attempt1, attempt2, attempt3, ROW_NUMBER() OVER(ORDER BY attempt1, attempt2, attempt3)
AS rank FROM Attempts
The query above works fine when I attempt to rank the values in one column say attempt1, but when I add the additional fields the ranking does not work the correct way. I am not sure what you be causing this. I tried the following solution Multiple columns in OVER ORDER BY but it does not seem to work.