Id name age salary
1 yzk 80 1000
2 yzk 80 2000
3 tom 20 20000
4 tom 20 20000
5 im 20 20000
使用Distinct 去重:
SELECT DISTINCT Name FROM Persons(Distinct 只能去除结果集中一模一样的数据)
获取不重复数据1:
SELECT Name, age FROM Persons GROUP BY Name, Gender
获取不重复数据2:
SELECT MAX(Id) AS Expr1, Name, Gender FROM Persons GROUP BY Name, age
获取不重复数据:
select * from Persons where Id in ( SELECT MAX(Id) AS Expr1 FROM Persons GROUP BY Name, age )
删除重复的数据:
delete from Persons where Id not in ( SELECT MAX(Id) AS Expr1 FROM Persons GROUP BY Name, age )