• ShawnBryan - Wednesday, February 28, 2018 12:10 PM

    Hello Steve,

    Seems yours code is ok .

    SELECT *
    FROM (
    SELECT ROW_NUMBER()
    OVER(PARTITION BY name
    ORDER BY name DESC) AS StRank, *
    FROM [d].[dbo].[t4]) n

    Thanks

    You still might benefit from adding an InsertedDate column to that table, so that you can use ORDER BY InsertedDate ASC as the ORDER BY clause in your ROW_NUMBER() function, as that would be more likely to result in the correct order.   Using the same column as the partition by will NOT guarantee that you get the order correct.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)