Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a rowid from a query 2

Status
Not open for further replies.

jmstarbuck

Programmer
Aug 11, 2003
90
US
Is there a way to select a row id from a query so that the rows selected in that query are numbered?

Something like "Select ? as rowid, a, b, c from tableF"

1 a b c
2 a b c
3 a b c

 
One way is to create a self join on the table.
For example.
SELECT Count(*) AS row, A.order
FROM TestOrder AS A, TestOrder AS B
WHERE (((B.Order)<=A.order))
GROUP BY A.order
ORDER BY A.order;

You could save this as a query, say with the row number and an ID and then join to your table in another query to supply the row number.
 
Thanks to both of you for your helpful suggestions. I've got it working!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top