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

Sometimes the simplest sounding things get me stuck

Status
Not open for further replies.

NYFashionToGo

Technical User
Jan 16, 2007
76
US
I have action queries that I run daily (sometimes more than once daily) right now I need to add a number to each line, for each record. First row = 1, 2nd =2 , 3rd =3.. why cant I figure this out.......... Does anyone know how I can achieve this... every time it can start with 1. I am stumpted.. Please advise. Thanks
 
In Access you can create a query and then join that query to a table. If the table has a unique ID then the table can be self joined to create a row number.

For instance, assume the table has a unique column called name.
SELECT Count(*) AS row, A.name
FROM [NameTable] AS A, [NameTable] AS B
WHERE A.name >= B.name
GROUP BY A.name;
Save this as a query, say called NameRank.

Now you can join this query to a table say called NameTable with a unique id of name.

Select
name,
row
From NameTable as A
Inner Join NameRank as B
On B.name = A.name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top