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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Count Field

Status
Not open for further replies.

chrisaroundtown

Technical User
Jan 9, 2003
122
AU
Hi,

I'd like a column in a query to show a record count next to each row. i.e. if I have got a query returing 10 records I'd like each row to have a number, which would be numbers 1 through to 10.

Any ideas on how I can do this?

Chris
 
Provided the table has an unique ID, you can create row numbers through a self join. Here is an example.

SELECT Count(*) AS row, A.ID
FROM TestOrder AS A, TestOrder AS B
WHERE ((B.ID)<=[A].[id])
GROUP BY A.ID
ORDER BY A.ID;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top