Runningsum or Record Number in Query?

P

Paul

In a query I am attempting to include a number
coorisponding to each record in a table. It would be nice
if I could extract the actual record (or row) number.
However, since the query does not limit records a
runningsum or row counter (incrementing number for each
row) would work.

Unfortunately, the solution has not presented itself to me
easily and I can not believe it's that "tough". Example:

(Needed) ID OtherStuff
1 1 xxxxxx
2 4 xxxxxx
3 5 xxxxxx

Ideas would be appreciated.
 
D

Dale Fye

Paul,

A database does not have record numbers, however, if your ID field is
sequential with no duplicates, then you could do the following:

SELECT (DCOUNT("ID", "yourtable", "ID <= " & T.ID) as SeqNum, ID,
otherstuff
FROM yourTable T

If you have a lot of records, this could take a while.
--
HTH

Dale Fye


In a query I am attempting to include a number
coorisponding to each record in a table. It would be nice
if I could extract the actual record (or row) number.
However, since the query does not limit records a
runningsum or row counter (incrementing number for each
row) would work.

Unfortunately, the solution has not presented itself to me
easily and I can not believe it's that "tough". Example:

(Needed) ID OtherStuff
1 1 xxxxxx
2 4 xxxxxx
3 5 xxxxxx

Ideas would be appreciated.
 
P

Paul

Dale,

I have taken your suggestion and put it into play. It
works like a charm!

Your solution is simple as I figured it would be, but it's
not obvious. I truely appreciate your response to my
S.O.S. It has helped me tremendously.

Paul
 
D

Dale Fye

Any time.

Glad I could help!

--
HTH

Dale Fye


Dale,

I have taken your suggestion and put it into play. It
works like a charm!

Your solution is simple as I figured it would be, but it's
not obvious. I truely appreciate your response to my
S.O.S. It has helped me tremendously.

Paul
 

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