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
 Sequencing

Author  Topic 

ben_53
Yak Posting Veteran

67 Posts

Posted - 2011-07-26 : 14:41:22
I have another issue while sequencing data in a tableA which has 3 columns. col1, col2 and sequence.
col1 can have 6 values, (A,B,C,D,E and F). This table is very big and number of rows can change.

in third column, sequence,
I want to sequence it like if col1 with A has 100 rows then sequence should be 0001, 0002 ... 0100
for B, it should start with 0101 and so on...

Also notice that I want sequence in order as (A, B, C, D, E and then F)

Thanks.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-26 : 14:46:38
Would a simple row_Number function ordered by col1 work for you? what I mean is something like this:
SELECT
ROW_NUMBER() OVER (ORDER BY Col1 ASC) AS Sequence
FROM
tableA
ORDER BY
col1
Go to Top of Page
   

- Advertisement -