这个问题我解决了,谢谢各位的帮助啊,用次语句可解决啦select shuju from pyk a
where (substr(shuju,-1,1)='B'
and not exists(select 1 from pyk where shuju = (substr(a.shuju,1,length(a.shuju) - 1)||'A')))
or
(substr(shuju,-1,1)='A'
and not exists(select 1 from pyk where shuju = (substr(a.shuju,1,length(a.shuju) - 1)||'B')));
SQL> create table pyk(shuju varchar2(20));
select *
from tbl a
where substr(a.dhhm,-1) in('A','B')
and not exists(
select 0
from tlb b
where substr(b.dhhm,1,length(b.dhhm)-1) = substr(a.dhhm,1,length(a.dhhm)-1)
);