日期:2014-05-17 浏览次数:20847 次
--方法1
WITH T AS (
SELECT 11111111111 AS A, 11111111111 AS B FROM DUAL UNION ALL
SELECT 22222222222 AS A, 22222222222 AS B FROM DUAL UNION ALL
SELECT 33333333333 AS A, 33333333333 AS B FROM DUAL UNION ALL
SELECT 55555555555 AS A, 44444444444 AS B FROM DUAL UNION ALL
SELECT 66666666666 AS A, 55555555555 AS B FROM DUAL UNION ALL
SELECT 77777777777 AS A, 66666666666 AS B FROM DUAL UNION ALL
SELECT 88888888888 AS A, 77777777777 AS B FROM DUAL UNION ALL
SELECT 99999999999 AS A, 88888888888 AS B FROM DUAL
)
(
SELECT T.A FROM T
UNION
SELECT T.B FROM T
)
MINUS
(
SELECT T.A FROM T
INTERSECT
SELECT T.B FROM T
)
--方法2
WITH T AS (
SELECT 11111111111 AS A, 11111111111 AS B FROM DUAL UNION ALL
SELECT 22222222222 AS A, 22222222222 AS B FROM DUAL UNION ALL
SELECT 33333333333 AS A, 33333333333 AS B FROM DUAL UNION ALL
SELECT 55555555555 AS A, 44444444444 AS B FROM DUAL UNION ALL
SELECT 66666666666 AS A, 55555555555 AS B FROM DUAL UNION ALL
SELECT 77777777777 AS A, 66666666666 AS B FROM DUAL UNION ALL
SELECT 88888888888 AS A, 77777777777 AS B FROM DUAL UNION ALL
SELECT 99999999999 AS A, 88888888888 AS B FROM DUAL
)
SELECT T.A FROM T
MINUS
SELECT T.B FROM T
UNION
(
SELECT T.B FROM T
MINUS
SELECT T.A FROM T
)