Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sequential number UPDATE query

Status
Not open for further replies.

sconly

Programmer
Oct 26, 2010
5
0
0
GB
I have a table called OrderDetails with the fields OrderID (existing field) and OrderLine (a new filed).

Below is a snippet of data.

OrderID OrderLine
-------------------------
10248 NULL
10248 NULL
10248 NULL
10249 NULL
10249 NULL
10250 NULL
10250 NULL
10250 NULL
10250 NULL
10250 NULL
10251 NULL
10251 NULL
10251 NULL

What I'm trying to do is UPDATE the OrderLine with a sequential number for each (same) OrderID. See below for an illustration.

OrderID OrderLine
-------------------------
10248 1
10248 2
10248 3
10249 1
10249 2
10250 1
10250 2
10250 3
10250 4
10250 5
10251 1
10251 2
10251 3

Can someone be kind enough to help me out - preferably with code - with my problem?

Thanks
 
Just to check,

Are those the only 2 fields in the table,
Is there any way to distincguish which occurence of the order number is labled as order line 1 or does it not matter?
Is there a maximum number of order lines?


I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
1. There are other fields but i'm only looking at updating the OrderLine field.

2. For this exercise it don't think it matters.

3. no

Hope that helps yoy?

Ta.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top