65.9K
CodeProject is changing. Read more.
Home

Reading Duplicate Values from the Table

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Apr 6, 2010

CPOL
viewsIcon

8873

Hi, on many occasions we want to search some repeated values in one or more columns. It is quite simple to do this...select ColumnName, count(ColumnName) as NumberOfTimesfrom TableNameGroup By ColumnNamehaving (count(ColumnName) > 1)At the same time, there is also a requirement...

Hi, on many occasions we want to search some repeated values in one or more columns. It is quite simple to do this...
select ColumnName, count(ColumnName) as NumberOfTimes
from TableName
Group By ColumnName
having (count(ColumnName) > 1)
At the same time, there is also a requirement to find how many rows with primary key have duplicate values:
select PrimaryKeyColumn,
from TableName
where ColumnNamein (
select ColumnName
from TableName
group by ColumnName
having (count(ColumnName) > 1