Question

Locked

Access: count index in a select query

By lital_hess ·
I would like to add to my query a count field, and I have no idea how....
the desired results is :

name |count
----------
xxx | 1
yyy | 2
zzz | 3

or

name | count
------------
zzz | 1
xxx | 2
yyy | 3

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

count(*)

by onbliss In reply to Access: count index in a ...

select name, count(*) from table group by name

Collapse -

Basically you can't, you can cheat with this though

by Tony Hopkinson In reply to Access: count index in a ...

create another table put in a rownumber field with an identity property and the other(s)

insert into myrowtable select name from mytable order by name.
as each row from the select is inserted the identity field increases by 1 (default)

When you've done drop the table.

May I ask why you want this, it's a very very very bad idea to make use of it for pointing to data in the database.

PS count is the number of records so

xxx
yyy
zzz
zzz

Would give
xxx 1
yyy 1
zzz 2

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums