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.
Author |
Topic |
zoe2003
Starting Member
17 Posts |
Posted - 2012-11-07 : 07:13:57
|
Hi,I need to add a counter for each change in 2 columns like following:this is the original table :column1 column21 21 21 31 41 52 102 112 122 152 20and I want a 3rd column like following:column1 column2 counter1 2 11 2 21 3 31 4 41 5 52 10 12 11 22 12 32 15 42 20 5Thanks,Z. |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2012-11-07 : 07:22:03
|
select *,ROW_NUMBER () OVER ( PARTITION BY column1 order by column1 ) as column3from AWhat you mean when You say "for each change in 2 columns" ?the exemple shown by you , only the change in column 1 |
|
|
zoe2003
Starting Member
17 Posts |
Posted - 2012-11-07 : 07:32:00
|
Thanks a lot ! This is what I needed. |
|
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2012-11-07 : 07:45:38
|
w. welcome |
|
|
|
|
|