1.取得不重复的数据

select * from Persons where Id in
(
SELECT    MAX(Id) AS Expr1
FROM    Persons
GROUP BY Name, Gender
)

2.删除重复的数据【MAX换成MIN会有不同的效果】(group by之后数据重复的只会留下一条)

delete from Persons
where Id not in
(
SELECT    MAX(Id) AS Expr1
FROM    Persons
GROUP BY Name, Gender
)

相关文章:

  • 2022-01-01
  • 2021-11-29
  • 2021-06-26
  • 2021-10-10
  • 2021-06-06
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-06-27
  • 2021-09-16
  • 2022-12-23
  • 2021-09-24
相关资源
相似解决方案