SQL: Show Row Record Counts or List Rows With Duplicates

5/7/2014 7:21:41 PM

The following will show row records counts. It can be used to show where there is duplicate data (userId in this case). This will show the count of the selected column(s).

SELECT		UserId,
			COUNT(*) AS DuplicateCount
		
FROM		MyTableWithUserIds

GROUP BY	UserId

HAVING		COUNT(*) > 1