[英]Query to select that records from the table having particular column value
[Ques description]I am having table of bills ,in this I don't want to show the records which is having Doctyp='BIL'
[问题描述]我有帐单表,在此我不想显示具有 Doctyp='BIL' 的记录
BILNO DOCTYP
1812B00001 BIL
1812B00001 RCR
ADVN CN
ADVN DA
ADVN RCD
ADVN RCR
ADVN TF
AL1707B00006 BIL
AL1707B00006 RCR
I want my output like我希望我的输出像
BILNO DOCTYP
ADVN CN
ADVN DA
ADVN RCD
ADVN RCR
ADVN TF
NOT IN
is one option: NOT IN
是一种选择:
SQL> with test (bilno, doctyp) as
2 (select 182, 'bil' from dual union all
3 select 182, 'xxy' from dual union all
4 select 111, 'abc' from dual union all
5 select 111, 'zdv' from dual union all
6 select 223, 'bil' from dual union all
7 select 555, 'xzy' from dual
8 )
9 select *
10 from test t
11 where bilno not in (select bilno
12 from test
13 where doctyp = 'bil');
BILNO DOC
---------- ---
111 zdv
111 abc
555 xzy
Another is NOT EXISTS
:另一个
NOT EXISTS
:
SQL> with test (bilno, doctyp) as
2 (select 182, 'bil' from dual union all
3 select 182, 'xxy' from dual union all
4 select 111, 'abc' from dual union all
5 select 111, 'zdv' from dual union all
6 select 223, 'bil' from dual union all
7 select 555, 'xzy' from dual
8 )
9 select *
10 from test t
11 where not exists (select null
12 from test t1
13 where t1.bilno = t.bilno
14 and t1.doctyp = 'bil'
15 );
BILNO DOC
---------- ---
111 zdv
111 abc
555 xzy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.