如果没有相应COlumnB为0的记录,则不显示

解决方案 »

  1.   

    select * from tbl as a where ColumnB=1 and exists
    (select * from tbl where ColumnB=0 and ColumnA=a.ColumnA)
      

  2.   

    select * from 表 t
    where exists(select 1 from 表 where columnA=t.columnA and columnB+t.columnB=1)
      

  3.   


    select * from tbl as a where ColumnB=1 and 
    (select IsNull(Count(*),0) from tbl where ColumnB = 0 and ColumnA=a.ColumnA) = 1
    Order By ColumnA Asc当有多条ColumnB 为0的纪录,对应一个ColumnA时,建议采用WangZWang(阿来) 的方法。
      

  4.   

    为何显示ERROR at line 1:
    ORA-00933: SQL command not properly ended我用的是Oracle9