select a 
from table a,table b
where a.id(+)=b.id
and a........这里该怎么写其中a的值包括 Y , N ,NULL三种
但我只想查出包括Y和N的值
只有Y或者只有N或者只有null的不显示1.null
2.Y
3.N
4.Y
  N
我想的到第四种结果,是否可以做到

解决方案 »

  1.   

    就是说,表a中有一个字段vat,其值有Y,N 两种值,但是我现在连接另外一个表后,可能会有多条记录
    select a.pc,a.vat 
    from table a,table b
    where a.id(+)=b.id
    and a.vat .....
    我只想得到a.vat即包含Y又包含N的值
    楼上两位是否明白?
    1.如果a.vat='N' 得PC110007   N
                      PC110008   N
    2.如果a.vat='Y' 得PC110001   Y
                      PC110002   Y
    3.如果a.vat=? 得  PC110005   N
                      PC110006   Y
    怎么得到第三种情况?
      

  2.   

    如果写a.vat='Y' or a.vat='N'的话可以得到上述三种效果,但我想要的条件是只得到第三种情况,要排除掉前两种情况
      

  3.   

    a.vat<>b.vat and a.vat is not null
      

  4.   

    不是这样的。关键是只有a表有vat这个字段,b表没有vat这个字段
      

  5.   

    select a_name
      from table_a a, table_b b
     where a.id(+) = b.id
       and exists (select 1
              from table_a c
             where c.id = a.id
               and c.a_name = 'Y'
                       
            )
       and exists (select 1
              from table_a d
             where d.id = a.id
               and d.a_name = 'N'
               )
      

  6.   

    select a  
    from table a,table b
    where a.id(+)=b.id
    and a.xxx(+) = xxxx