Say I have the query below:
WITH TEMP AS
(
select 1 as id, 4 as value
UNION
SELECT 2, 53
UNION
SELECT 3, 1
UNION
SElECT 4, 474
UNION
SELECT 5, 53
)
SELECT *,
ROW_NUMBER() OVER (ORDER BY value)
FROM TEMP
This returns the following:
3 1 1
1 4 2
2 53 3
5 53 4
4 474 5
I would like two rows with 53 to have the same row number (3) and the final row to keep it’s row number of 5. I assume this cannot be done using ROW_NUMBER. Can anyone point me in the right direction to get me started on this?
Instead of using
ROW_NUMBER, you want to useRANK.RANK (T-SQL) MSDN Reference