0

我在删除具有不同列的行中的重复数据时遇到问题:

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

4

1 回答 1

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;
于 2013-01-16T10:29:19.277 回答