直接在语句最后面加一个 group by 你想去重的内容 SELECT * FROM student1 group by id ;想这样?但这样是错的; 如果改为 SELECT id FROM student1 GROUP BY id; 这样查询出来就只有id这一项; select *, count(distinct id) from table group by id; 这个不知道对不对,很早之前能用,现在不知道对不对,如果能输出结果,结果的最后会多一个去重的计数;
--查询 select * from (select name,ROW_NUMBER() over(partition by name order by id) n from student1 )t where n>1 --删除 delete t from (select name,ROW_NUMBER() over(partition by name order by id) n from student1 )t where n>1