• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1966
  • Last Modified:

Access query to provide a sequence number

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
Alphacircuits
Asked:
Alphacircuits
  • 2
  • 2
1 Solution
 
Rey Obrero (Capricorn1)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];
0
 
AlphacircuitsAuthor Commented:
Ok, I have I added the ID to the table, but I am not sure where to insert the select statement you provided?
0
 
Rey Obrero (Capricorn1)Commented:
In your original post, you were asking for

Access query
0
 
AlphacircuitsAuthor Commented:
Thanks!
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now