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
 Assigning same value to duplicate records

Author  Topic 

pankaj.malhotra
Starting Member

5 Posts

Posted - 2009-05-13 : 00:52:13
Hi,

I have to generate a increment value for combination of 2 other columns. If it finds a duplicate value while combining the other 2 column, it should assign the same value.

for example

Lets say we have a table like

a b c
ABC DEF 1
ABC DEF 1
ABD DEF 2
ABE DEF 3
ABE DEF 3
ABE DEG 4

Column C is the increment value. whenever it is finding duplicate value while concatenating Column A and B, It is populating the same value in that column.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-13 : 01:02:30
use

dense_rank() over(order by a, b)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

pankaj.malhotra
Starting Member

5 Posts

Posted - 2009-05-13 : 01:37:27
thanx. it works
Go to Top of Page
   

- Advertisement -