How do I number each record in a query (1, 2, 3...)

G

Guest

I want to number each record in a query using a sequencial number from 1-3
and the start over, example:

Sequence #
Record A 1
Record B 2
Record C 3
Record D 1
Record E 2
....
 
D

Duane Hookom

You need to identify an ordering field. The following is an example using
the Customers table in Northwind.mdb.

SELECT Customers.CustomerID,
(SELECT Count(*)
FROM Customers C
WHERE C.CustomerID <Customers.CustomerID) Mod 3+1 AS SeqNum
FROM Customers
ORDER BY Customers.CustomerID;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top