David Graig
David Graig

Reputation: 153

SQL items Smart rating

trying to get normal price rating using

ROW_NUMBER() OVER(PARTITION BY [id] ORDER BY [price] asc) as [Rating]

Result that I have now

But I need rating like:

enter image description here

I know thats suppose to be easy - but google didnt gave me any idea. Need you help

Upvotes: 0

Views: 33

Answers (1)

diiN__________
diiN__________

Reputation: 7666

Take DENSE_RANK() instead of ROW_NUMBER(). Then it should work:

DENSE_RANK OVER(PARTITION BY [id] ORDER BY [price] ASC) AS [Rating]

Upvotes: 1

Related Questions