Member_2_1316035
asked on
Calculate auto sequence number for grouped records in query
I need to group records in a query and create a new column which assigns an auto-incrementing sequence number for the returned rows per group.
Using the example below, I group on ID and TYPE, sort by SEQ, and return an auto incrementing number for each group.
Example Data
ID TYPE SEQ AUTOSEQ
001 M 1 1
001 N 2 1
001 N 3 2
001 M 4 2
001 N 5 3
002 M 1 1
002 M 2 2
002 N 3 1
Using the example below, I group on ID and TYPE, sort by SEQ, and return an auto incrementing number for each group.
Example Data
ID TYPE SEQ AUTOSEQ
001 M 1 1
001 N 2 1
001 N 3 2
001 M 4 2
001 N 5 3
002 M 1 1
002 M 2 2
002 N 3 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm trying to wrap my head around how that actually works - but it is perfect, thanks!