select distinct id from A where flag<>'X'

解决方案 »

  1.   

    select distinct id from A where NVL(flag,'')<>'X'
      

  2.   

    select distinct id from A where NVL(flag,'')<>'X'
    似乎效率太低,因为id有3000多个,每个id对应的item有30多个
      

  3.   

    select distinct id from a where flag='x' and id not in(select id  from a where flag<>'x' or flag is null) 看看这个!
      

  4.   

    select distinct id from a where id not in(select id  from a where flag<>'x' or flag is null) 这样也可以的,试试!
      

  5.   

    楼上的选择的是相反的记录吧.如果那样效率也不会很好.
    我也来写一个:
    select distinct id from (select id from a minus select id from a where flag='x')
    不知道行不行,没试.还是顶楼来的快.
      

  6.   

    试试俺的,哇哈哈~~~select id from a where flag<>'X' group by id
      

  7.   

    select distinct id from A 
    where id not in (select distinct id from A where nvl(flag,'#')<>'X' );用nvl函数呗~
      

  8.   

    8好意思,上面写的那个反了,试试这个:
    select distinct id from A where nvl(flag,'#')<>'X' ;