Link to home
Start Free TrialLog in
Avatar of alankwan
alankwan

asked on

How to retrieve data with running number using access query ?

How to retrieve datas with running number using access query ? eg. i got three data ...then show me 1 ... 2 .. 3 ...
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Hi alankwan

If you have a numeric primary key field in your table, autonumber is good, you can do something like this:

SELECT (Select count(*) from TheTable where ID <=T.ID) AS [Counter], T.ID
FROM TheTable AS T

Returns:

Counter      ID
1      1
2      2
3      3
4      5

Alan

Avatar of alankwan
alankwan

ASKER

thank you ...but it not works if i got 'where' clause to filter data
ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial