sql - Incremental count column based on another column contents -


I have to fill one column with the calculation to run on the basis of the second column content. The table is like this:

 counting seq_num 1 123-456-789 1 123-456-780 1 123-456- 990 2 123-456-78 9 2 123-456-990 
< P> So, as the seq_num column changes, the counter relies on '1' and repeats as the column, the counter increase from 1

This is using SQL2000, and the seq_num field is varchar.

Any thoughts? I have seen something like this but there is no luck yet. Thanks in advance

If you will enter , You can use a subquery:

  Include in the table (count, seq_num) value ((Select from the table Select number (*) + 1 where seq_num = @seq) , @ Seq)  

Otherwise, you will need a date there or there is a way to tell how to decide what was earlier:

  update table T calculation = (selectable number (*) + 1 table where t2.seq_num = the T2 table.seq_num and t2.insertdate & lt; table.insertdate)  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -