Query in Access 2007

S

ShelleyS

I have linked via ODBC tables from another database. I have created a query
to pull in two columns of information from the two tables in the query. I
would like to add an extra column that is only created when the query is run,
to dynamically number each row incrementally, depending on how many rows the
query returns. If it returns 10 rows, then the first column should be
numbered 1 to 10, if it returns 357 rows, then the rows should automatically
incrementally number each from from 1 to 357.
 
K

KARL DEWEY

Try this but substitute your table and field names. Prim is your primary
key. This can only be viewed in SQL view.
SELECT a.Column1, (COUNT(*)) AS Row
FROM [YourTable-4] AS a LEFT JOIN [YourTable-4] AS b ON a.Prim>=b.Prim
GROUP BY a.Column1;
 

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