query

S

Saeed

been a while doing SQL programming , its all wiped.
If i have a table with a field say refNo

1001
1002
1003
1001



How woud I be able to get a query telling me the distinc RefNo's with
the number of occurance (duplicates in the table for each RefNo)

Something like

1001 2
1002 1
1003 1


Cheers
 
J

John W. Vinson

been a while doing SQL programming , its all wiped.
If i have a table with a field say refNo

1001
1002
1003
1001



How woud I be able to get a query telling me the distinc RefNo's with
the number of occurance (duplicates in the table for each RefNo)

Something like

1001 2
1002 1
1003 1


Cheers

A simple TOTALS query:

SELECT RefNo, Count(*)
FROM tablename
GROUP BY RefNo;

In the query grid, add the table; Group By the field you want distinct; and
add the field a second time and choose Count.
 

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

Similar Threads


Top