Results 1 to 3 of 3

Thread: number rows

  1. #1
    Join Date
    Feb 2005
    Posts
    76

    Unanswered: number rows

    I have wrote a query that returns product details for all orders that are at stage 6. Is there a way to number the product lines in each order no?!

    Eg.
    Order 1
    Product 1 - 1
    Product 2 - 2
    Product 3 - 3

    --counter restarts
    Order 2
    Product 1 - 1
    Product 2 -2

    thanks?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    If you are using SQL 2005, you could look into using the ROW_NUMBER function with the PARTITION BY option.

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Or you can just let the front end do it..or insert the rows into a temp table with an identity column then select from that
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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