您的位置:首页 > 数据库

SQL Tips: How to detect duplicate rows in table

2013-09-06 08:19 549 查看
For example:

-- O: Original table
-- D: Duplicate records table

select O.*, D.RecCount
from tblFunctionality O
inner join
(
select FunctionalityName, IsGroup, ParentId, COUNT(*) AS RecCount
from tblFunctionality
group by FunctionalityName, IsGroup, ParentId
having COUNT(*) > 1
) D
on
O.FunctionalityName = D.FunctionalityName AND
O.IsGroup = D.IsGroup AND
O.ParentId = D.ParentId
order by O.FunctionalityName, O.IsGroup, O.ParentId;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐