Last active
March 11, 2022 13:55
Star
You must be signed in to star a gist
重复记录过滤.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with main_table as ( | |
... | |
) | |
SELECT | |
a.* | |
FROM | |
main_table as a | |
WHERE | |
NOT EXISTS | |
( | |
SELECT | |
1 | |
FROM | |
main_table as b | |
WHERE | |
-- main_table的重复字段 | |
a.field1 = b.field1, | |
a.field2 = b.field2 | |
-- 修改上面 | |
-- 较大的一条 用'<', 较小的一条用'>' | |
AND a.cmp_field < b.cmp_field | |
-- 修改上面 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment