sql单字段,多字段去重

---单字段去重复记录
select * from fbs_corp_budget b WHERE b.corp_id IN ( SELECT d.corp_id FROM fbs_corp_budget d GROUP BY d.corp_id HAVING COUNT(d.corp_id) > 1)
AND ROWID NOT IN (SELECT MIN(ROWID) FROM fbs_corp_budget c GROUP BY c.corp_id HAVING COUNT(*) > 1);

---多字段去重
delete from 学生表 a where (a.学号,a.姓名,a.课程编号,a.课程分数,a.课程名称)
in (select a.学号,a.姓名,a.课程编号,a.课程分数,a.课程名称 from 学生表 group by a.学号,a.姓名,a.课程编号,a.课程分数,a.课程名称 having count(*) > 1)
and rowid not in (select min(rowid) from 表 group by a.学号,a.姓名,a.课程编号,a.课程分数,a.课程名称 having count(*)>1)

posted @ 2020-12-22 09:43  凉了记忆  阅读(1474)  评论(0编辑  收藏  举报