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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Giving duplicate rows the same number

Author  Topic 

jcw12000
Starting Member

5 Posts

Posted - 2012-01-16 : 10:00:42
I have a issue.

I ran a duplicate script to get all the duplicate rows in my data.

Now what I need to do is to give the duplicates a value example:

Below is my data of duplicates:

INV Date duplicate key Invoice_Value
1 2012/01/01 krty4 67.98
1 2012/01/01 krty4 67.98
45 2011/02/03 kjn56 10.01
45 2011/02/03 kjn56 10.01


Below is the results I need:

INV Date duplicate key Invoice_Value Value
1 2012/01/01 krty4 67.98 1
1 2012/01/01 krty4 67.98 1
45 2011/02/03 kjn56 10.01 2
45 2011/02/03 kjn56 10.01 2

And so on.

So for each set of duplicates according to invoice value desc I need to almost put in a rank but the rank must be the same for the whole set of the specific duplicate

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 10:11:12
[code]
SELECT DENSE_RANK() OVER (ORDER BY [Date]) AS Value,*
FROM Table
[/code]

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

Go to Top of Page
   

- Advertisement -