Runningsum or Record Number in Query?

  • Thread starter Thread starter Paul
  • Start date Start date
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.
 
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.
 
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
 
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
 
Back
Top