Counting duplicate records

Finding the number of times a particular value occurs in a set of records, or even the number of times a record is present in a table can be very helpful.

I found the query below and have used it several times. It’s simply, and easy to modify to suit.

SELECT YourColumn, COUNT(*) TotalCount
FROM YourTable
-- WHERE YourColumn = 'ThisValue'
GROUP BY YourColumn
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC

Find the original post here.

Subscribe

0 comments