tags:

views:

34

answers:

3

Database Name = MyDB

Table Name = MyTable

Column Name = ColumnSurname

Using SQL Server 2005

I have multiple entries in ColumnSurname and some of them are spelled exactly the same. How can i return all the distinct values with the same ColumnSurname value. Meaning i want to return "Bond" if "Bond" comes up more than twice.

How would i do this in a SQL statement?

+5  A: 

SELECT ColumnSurname FROM MyTable GROUP BY ColumnSurname HAVING COUNT(ColumnSurname) > 1 ?

Locksfree
+1  A: 
SELECT ColumnSurname FROM MyTable GROUP BY ColumnSurname HAVING count(*)>1
culebrón
+1  A: 
select ColumnSurName, count(*) from MyTable group by ColumnSurName having count(*) >1

If you want to see how many duplicates you have

Alexey Sviridov