Solved

Access query to provide a sequence number

Posted on 2014-03-03
4
1,352 Views
Last Modified: 2014-03-06
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
0
Comment
Question by:Alphacircuits
  • 2
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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];
0
 

Author Comment

by:Alphacircuits
Comment Utility
Ok, I have I added the ID to the table, but I am not sure where to insert the select statement you provided?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
In your original post, you were asking for

Access query
0
 

Author Closing Comment

by:Alphacircuits
Comment Utility
Thanks!
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now