日期:2014-05-17 浏览次数:21324 次
WITH T AS
(SELECT 1 PID, 'a,b' FMODEL, 'b,a' SMODEL FROM DUAL
UNION ALL
SELECT 2 PID, 'a,b,c' FMODEL, 'c,a,b' SMODEL FROM DUAL
UNION ALL
SELECT 3 PID, 'a,c,d' FMODEL, 'c,a,b' SMODEL FROM DUAL)
SELECT *
FROM T
WHERE NOT EXISTS
(SELECT 1
FROM (SELECT PID, REGEXP_SUBSTR(FMODEL, '[^,]+', 1, LEVEL) FMODEL
FROM T
CONNECT BY LEVEL <=
LENGTH(FMODEL) - LENGTH(REPLACE(FMODEL, ',', '')) + 1
AND PID = PRIOR PID
AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
MINUS
SELECT PID, REGEXP_SUBSTR(SMODEL, '[^,]+', 1, LEVEL) SMODEL
FROM T
CONNECT BY LEVEL <=
LENGTH(SMODEL) - LENGTH(REPLACE(SMODEL, ',', '')) + 1
AND PID = PRIOR PID
AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL) T1
WHERE T1.PID = T.PID)