Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在删除具有不同列的行中的重复数据时遇到问题:
SELECT p1, p2 FROM (SELECT 'A' AS p1, 'B' AS p2 FROM DUAL UNION SELECT 'B' AS p1, 'A' AS p2 FROM DUAL) a;
结果将是:
P1 P2 -- -- 甲,乙 乙,甲
我只需要 A,B 或 B,A
SELECT distinct least(p1, p2), greatest(p1, p2) FROM (SELECT 'A' AS p1, 'B' AS p2 FROM DUAL UNION SELECT 'B' AS p1, 'A' AS p2 FROM DUAL) a;