I am having issues with a query, I want it to rank the result based on the time the last change was recorded.
SELECT
ROW_NUMBER() OVER (PARTITION BY ph.pricingHistoryId ORDER BY ph.changeRecorded DESC),
ph.*
FROM
PriceHistory ph
It returns all 1 for the ranking.
If
pricingHistoryIdis the Primary Key, Partitioning by it always returns the rank as 1 because there cannot be repetitive primary keys!