我在删除具有不同列的行中的重复数据时遇到问题:
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
我只需要A,B或B,A
答案 0 :(得分:0)
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;