I would like a SQL query for MS Jet 4.0 (MSSql?) to get a count of all the duplicates of each number in a database.
The fields are: id
(autonum), number
(text)
I have a database with a lot of numbers.
Each number should be returned in numerical order, without duplicates, with a count of all duplicates.
Number-fields containing 1, 2, 2, 3, 1, 4, 2 should return:
1, 2
2, 3
3, 1
4, 1
SELECT col,
COUNT(dupe_col) AS dupe_cnt
FROM TABLE
GROUP BY col
HAVING COUNT(dupe_col) > 1
ORDER BY COUNT(dupe_col) DESC
SELECT number, COUNT(*)
FROM YourTable
GROUP BY number
ORDER BY number
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With