原理:对需要去重复记录的字段按组排序,然后取其中一条记录。在总查询语句中使用in语法过滤
去掉重复记录
select * from company where comid in (select Max(comid) from company group by companyname)
得到重复记录数
select * from company where comid not in (select Max(comid) from company group by companyname)
去掉重复记录
select * from company where comid in (select Max(comid) from company group by companyname)
得到重复记录数
select * from company where comid not in (select Max(comid) from company group by companyname)
对完全相同的记录可以使用DISTINCT 对记录进行唯一性过滤
本文转自灵动生活博客园博客,原文链接:http://www.cnblogs.com/ywqu/archive/2009/10/11/1580851.html,如需转载请自行联系原作者