select fvolume,fcode, fname from tb_secpossession where fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-8','yyyy-mm-dd') and fvolume <> 0
结果如下: select * from tb_secpossession where fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-31','yyyy-mm-dd') and fcode ='002203'
fcode为上表中每一个fcode。
如何合并成一条语句?

解决方案 »

  1.   

    select 你要的字段 from tb_secpossession where (fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-8','yyyy-mm-dd') and fvolume <> 0) or (fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-31','yyyy-mm-dd') and fcode ='002203')
      

  2.   

    sorry,看走眼了
    select * from tb_secpossession where fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-31','yyyy-mm-dd') and fcode in (select fcode from tb_secpossession where fsetid = 'SB0204' and ftype='GP' and fdate = to_date('2008-1-8','yyyy-mm-dd') and fvolume <> 0)