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 2000 Forums
 SQL Server Development (2000)
 Identity per group

Author  Topic 

jparker
Posting Yak Master

118 Posts

Posted - 2007-03-05 : 10:30:45
Hello

I want to achieve an incremental id per pack type. So for example I have an output of

Pack ID | Firstname | Surname |
8 | Andrew | Flintoff |
8 | Jacob | Oram |
10 | Andy | Pandy |
10 | Super | Ted |
10 | Banana | Man |

what I want to achieve is

ID | Pack ID | Firstname | Surname |
1 | 8 | Andrew | Flintoff |
2 | 8 | Jacob | Oram |
1 | 10 | Andy | Pandy |
2 | 10 | Super | Ted |
3 | 10 | Banana | Man |

Where ID is a new incremental pack count

I can of course do it with a series of temporary tables or a loop of sorts but wondered what the consensus of opinion was to most efficiently provide this via a select statement

Your thoughts would be most appreciated

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-03-05 : 11:15:49
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx
point 1

Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jparker
Posting Yak Master

118 Posts

Posted - 2007-03-05 : 11:27:54
Thanks
Go to Top of Page
   

- Advertisement -