日期:2014-05-17 浏览次数:20999 次
WITH t AS
(
SELECT 1 XH,1 XB, 18 NL FROM dual
UNION ALL
SELECT 2,2, 20 FROM dual
UNION ALL
SELECT 3,1, 20 FROM dual
UNION ALL
SELECT 4,2, 18 FROM dual
)
SELECT COUNT(1) FROM t WHERE xh NOT IN
(
SELECT xh FROM t WHERE xb=1 AND nl=20
)
--RESULT:
3
------解决方案--------------------
select t.* from tb t where not exists(select 1 from tb where xb=t.xb and nl=t.nl and xb=1 and nl=20)