Link to home
Start Free TrialLog in
Avatar of Member_2_1316035
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
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America 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 Member_2_1316035
Member_2_1316035

ASKER

Brilliant!

I'm trying to wrap my head around how that actually works - but it is perfect, thanks!