record counting in the same group

G

Guest

Hello all,
I need count records in a query for every type of Field in a table. Data
example:

ID Field
1 aaaaa
2 aaaaa
3 aaaaa
4 bbbbb
5 bbbbb
6 ccccc

and I need something like this:

ID Field Counter
1 aaaaa 1
2 aaaaa 2
3 aaaaa 3
4 bbbbb 1
5 bbbbb 2
6 ccccc 1

any idea ? Please help me......
Thanks in advance...
 
T

Tom Ellison

Dear Hans:

A query solution would be:

SELECT ID, Field,
(SELECT COUNT(*) + 1 FROM YourTable T1
WHERE T1.Field = T.Field AND T1.ID < T.ID) AS Counter
FROM YourTable T
ORDER BY Field, ID

Does this help?

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
G

Guest

I need something like this, but only counting the duplicates in the field and
adding three fields each with its own value of one when the value is present.
Field1
xxxx
xxxx
yyyy
zzzz
Fieldx Fieldy Fieldz
2 1 1
Thanks ahead! P.S. Sorry for the off reply. Need Help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top