score:8

Accepted answer

You need to remove the partition by clause from your query. Just use order by clause.

SELECT ProdID, Years, Months, Quantity,
DENSE_RANK()OVER (Order By Years, Months) Ranks
FROM Products

score:1

The following query should do what you want:

SELECT
    ProdID, Years, Months, Quantity,
    DENSE_RANK()OVER (ORDER BY  CAST(CAST(MONTHS AS VARCHAR)+'-01-'+CAST(YEARS AS VARCHAR) AS DATE)) Ranks
FROM Products

More questions

More questions with similar tag