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)
 Create unique sequence with Group By

Author  Topic 

tsiegle
Starting Member

9 Posts

Posted - 2003-03-27 : 23:37:47
Can anyone refresh my memory with an easy way to create a unique sequence based on the grouping of a column. I have done it before and know there is a simple way, I just can't figure it out!

For example, my table contains GrantID and SEQ as Primary key columns, then CaseID and LawID. There may be multiple GrantIDs of 15, because they have different LawID. i.e.

SEQ GrantID LawID
1 15 50
2 15 52
1 16 50

So, I just want to be able to auto create that SEQ column, based on a group By GrantID. If there are 3 LawID's then the records would be 1, 2, 3...if not SEQ would just be one.

Please please help!

Thank you!
Tracy

Thanks!

Tracy Siegle

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2003-03-28 : 00:12:12
Check out Jeff Smith's article on Streaks and Runs in data:
http://www.sqlteam.com/Item.asp?ItemID=12654

Sarah Berger MCSD
Go to Top of Page
   

- Advertisement -