Sequential Numbering on field in Access

R

robertadamharper

I need to sequence number Orders at a Site level with the last order
starting with number one and going up based on orders date. My example
is below;-

Site_URN Order_Date Order Number Seq Num
602547842 2004-10-31 154654 5
602547842 2005-11-01 154661 4
602547842 2006-10-01 154665 3
602547842 2007-01-02 154673 2
602547842 2007-01-03 154678 1


Can anyone help?
 
G

Gary Walter

robertadamharper said:
I need to sequence number Orders at a Site level with the last order
starting with number one and going up based on orders date. My example
is below;-

Site_URN Order_Date Order Number Seq Num
602547842 2004-10-31 154654 5
602547842 2005-11-01 154661 4
602547842 2006-10-01 154665 3
602547842 2007-01-02 154673 2
602547842 2007-01-03 154678 1
{untested}

SELECT
t.Site_URN,
t.Order_Date,
t.[Order Number],
(SELECT
Count(*)
FROM
yurtable As q
WHERE
q.Site_URN = t.Site_URN
AND
q.Order_Date>=t.Order_Date) As SeqNum
FROM
yurtable As t;
 

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