Link to home
Start Free TrialLog in
Avatar of canuckconsulting
canuckconsultingFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Update records with their occurance with a group

I have a t-SQL problem I can't get my head around.  I have a table of orders with each order having a unique alpha OrderNo.  Each order is associated with a BaseOrder in a many to one relation ship (one baseorder can have multiple orders).

The issue I have is I need to update the table and set a column to indicate the count of the order within the associated base order.  The example below indicates what I am after.  Orders 10001, 10012, 10018 and 1001A are all associated with BaseOrder 10001.  I need to update the SubOrderNumber with 1, 2, 3, 4 respectively as I want them stamped in incremental order based on their alpha sort order.


User generated image
ASKER CERTIFIED SOLUTION
Avatar of Haris Dulic
Haris Dulic
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of canuckconsulting

ASKER

Fabulous!  I had never heard of the over clause...what a handy tool!

Thanks,

Scott