Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Setting a # to specific values from diff column

Author  Topic 

kotonikak
Yak Posting Veteran

92 Posts

Posted - 2012-06-14 : 12:08:09
This is probably a really easy question but I can't seem to figure out how to set the following increasing sequence numbers to the decreasing LossAmount values:

Sequence LossAmount
1 1000
1 1000
2 900
3 800
3 800
3 800

When I didn't have repeating LossAmount values, I found the sequence by doing the following:

seq = ROW_NUMBER() over (order by LossAmount desc)

which is nice and easy....but now I'm not quite sure how to do it for repeated values.

Should be an easy question but I'm stuck...any help is appreciated!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-14 : 12:10:17
seq = DENSE_RANK() OVER (ORDER BY LossAmount DESC)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kotonikak
Yak Posting Veteran

92 Posts

Posted - 2012-06-14 : 12:13:40
thanks!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-14 : 12:20:55
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -