所有重复的记录:
select * from t_group t
where c_ou in (select c_ou from t_group group by c_ou having count(c_ou) > 1)
查询出比较晚入库的重复记录
select COUNT(*) from t_group t where t.ROWID !=(
select min(g.ROWID) from t_group g where g.c_ou=t.c_ou
)
本文介绍两种SQL查询中去除重复记录的方法。一种是找出所有重复的数据,另一种是仅保留较新的记录,通过ROWID来确定记录的先后顺序。
所有重复的记录:
select * from t_group t
where c_ou in (select c_ou from t_group group by c_ou having count(c_ou) > 1)
查询出比较晚入库的重复记录
select COUNT(*) from t_group t where t.ROWID !=(
select min(g.ROWID) from t_group g where g.c_ou=t.c_ou
)

被折叠的 条评论
为什么被折叠?
