Identify sql Duplicate Count


with CTE (Sectionid,sectionname,DC)
as
(
Select Sectionid,Sectionname,Row_number() over(partition by sectionid order by sectionid) as DC from sectiondefs
)
Select * from cte where DC >1

Select sectionid,count(sectionid)  from sectiondefs  group by sectionid  having count(sectionid) >1

Comments