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 |
Kalaiselvan
Posting Yak Master
112 Posts |
Posted - 2015-05-08 : 06:49:21
|
hi,I got a table with column GroupID. Where as the GroupID number will be repeated for specific column and some may be 0. Need to re-Order the GroupID with unique Id for respective Old GroupID. TableA:[ITEM] [SUBITEM] [GROUPID] PEN A 1PENCIL A 1INK PEN A 1ERASER A 1SCALE A 1 PEN B 1PENCIL B 1INK PEN B 2ERASER B 3SCALE B 4 PEN C 1PENCIL C 2INK PEN C 3ERASER C 4SCALE C 5 PEN D 1PENCIL D 0INK PEN D 0ERASER D 2SCALE D 3Required Output:[ITEM] [SUBITEM] [GROUPID] [NEWGROUPID] PEN A 1 1PENCIL A 1 1INK PEN A 1 1ERASER A 1 1SCALE A 1 1 PEN B 1 2PENCIL B 1 2INK PEN B 2 3ERASER B 3 4SCALE B 4 5 PEN C 1 6PENCIL C 2 7INK PEN C 3 8ERASER C 4 9SCALE C 5 10 PEN D 1 11PENCIL D 0 0INK PEN D 0 0ERASER D 2 12SCALE D 3 13You can see the new groupID contains uniqueID for each group. Help me to fix this Issue.Regards,Kalai |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-05-08 : 09:31:23
|
Not following the logic here. For example, in the original we have (PENCIL, A, 1) and (PENCIL, B, 1) (in the same group) but in the new version we have (PENCIL, A, 1,1) and (PENCIL, B, 1,2)Why is the new group id for (PENCIL, B) different? You required 'GroupID with unique Id for respective Old GroupID.' but that is not what your sample result shows.Gerald Britton, MCSAToronto PASS Chapter |
|
|
|
|
|
|
|