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
そして、私は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;