Add Number To Query

  • Thread starter Thread starter Bryan Hughes
  • Start date Start date
You don't. The record number is meaningless. If you want to associate a
number with your records, create a field and store a number. (invoice
number, client number, etc.)
 
Sorry, I was to vague.

What I need is to create row numbers in the query, like you can in a report.

1. Record 1
2. Record 2
3. Record 3

I know it can be done because I have done it before, I just can rember how I
did it.

-TFTH
 
As the other poster said: You don't! Because it's meaningless in a query.

If you need it in a report, you can do it there, but what do you need it for in a query? How do you want your records numbered if you change the 'ORDER BY' from ascending to descending, do you want the record number (or RowId) to change too?

If you insist, you can write a query along this lines (ID is :

SELECT T1.ID,
(Select Count(*) + 1
From MyTable As T2
Where T2.id < T1.id) AS RowID,
T1.Column2, T1.Column3, ...
FROM MyTable AS T1
--WHERE T1.ID < 1000

Hth
PerL
 
Back
Top