Access query to provide a sequence number

Alphacircuits
Alphacircuits used Ask the Experts™
on
How do I add a field to a query that is a numerical sequence (1,2,3...) that resets back to 1 each time an item changes

P/N    Seq
1         1
1         2
1         3
2         1
2         2
3         1
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
you need a unique id for each record. [ID] in the query could be an autonumber field

select Yourtable.[P/N],(select count(*) from Yourtable as T where T.[P/N]=Yourtable.[P/N] and T.id>=Yourtable.ID) as Seq
from Yourtable
order by Yourtable.[P/N];

Author

Commented:
Ok, I have I added the ID to the table, but I am not sure where to insert the select statement you provided?
Top Expert 2016

Commented:
In your original post, you were asking for

Access query

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial