所以我的头衔可能没有意义。这就是我想要做的事情。
C1 C2 C3
A1 yes X1
A2 no X1
A3 maybe X1
A4 yes X2
所以我的条件是C2<>'不'。在这种情况下,我希望结果只包括
C1 C2 C3
A4 yes X2
感谢您的帮助人员!
答案 0 :(得分:2)
使用minus
获取c3
no
c2
的所有 select * from table
where c3 in(
select distinct c3 from table
minus
select distinct from table where c2 = 'no' )
列表。并从表中仅选择那些行。
ReadAsync
答案 1 :(得分:0)
你可以尝试:
with x as (
select 'a1' as col1, 'yes' as col2, 'x1' as col3 from dual
union all
select 'a2' as col1, 'no' as col2, 'x1' as col3 from dual
union all
select 'a3' as col1, 'maybe' as col2, 'x1' as col3 from dual
union all
select 'a4' as col1, 'yes' as col2, 'x2' as col3 from dual
)
select *
from x
where not exists (
select 1
from x x2
where x2.col3 = x.col3
and x2.col2 = 'no'
);
输出:
COL1 COL2 COL3
a4 yes x2
答案 2 :(得分:0)
一个简单的NOT IN就应该这样做。
Select *
From Table
Where C3 Not In ( Select C3
From Table
Where C2 = 'no')