Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    1

    Unanswered: Update column with running numbers

    Hi,
    Can anyone tell me how I can use an SQL statement to update one of my columns with running numbers group by another column.
    Example:
    Assuming, I have a table with 2 fields :
    BillNo and lineNumber
    001, 2
    001, 10
    001, 3
    002, 11
    002, 1

    I wish to update the linenumber with running numbers starting with 1 but I need this number to restart from 1 again when the BillNo changes, so that it becomes the following :

    001, 1
    001, 2
    001, 3
    002, 1
    002, 2

    Anyone has any ideas?

    thank you.
    Last edited by tanm; 05-26-04 at 05:21.

  2. #2
    Join Date
    Nov 2002
    Posts
    207
    I don't think you can do it in one SQL, cursor would be an option.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •