SQL query to find duplicate values in a column

 
Here is a useful sql query to help identify duplicate values in a column and return a count of the number of times that value appears.  In this case I am determining duplicate usernames in the contact table.
 
SELECT New_Username, COUNT(New_Username) AS NumberOfTimes
FROM Contact
GROUP BY New_Username HAVING (COUNT(New_Username)>1)
ORDER BY NumberOfTimes DESC
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: