SQL 查询出 重复的数据:保留 id 最大值的记录
本地测试 案例
(1)查询 重复数据:
select a.* from "albert_test_a" a where exists (select b.* from "albert_test_a" b where b."email" = a."email" and b.id> a.id)
(2)删除 重复数据:
delete from "albert_test_a" a where exists (select b.* from "albert_test_a" b where b."email" = a."email" and b.id> a.id)
织信低代码系统 案例
(1)查询 重复数据:
select a.* from "z_0Z6t6t3lczX7fhcH" a where exists (select b.* from "z_0Z6t6t3lczX7fhcH" b where b."0Z6t6t3eN2K8U1Yj" = a."0Z6t6t3eN2K8U1Yj" and b.row_number > a.row_number)
(2)删除 重复数据:
delete from "z_0Z6t6t3lczX7fhcH" a where exists (select b.* from "z_0Z6t6t3lczX7fhcH" b where b."0Z6t6t3eN2K8U1Yj" = a."0Z6t6t3eN2K8U1Yj" and b.row_number > a.row_number)