我现在查询出来的结果如下
id xm je bh
01 aa 23 20061012
01 aa 30 20061013
01 aa -23 20061012
01 aa 40 20061014现在这些记录中je和的值一个是正23一个是负23而bh是一致的
怎样能得到下面的结果
id xm je bh
01 aa 30 20061013
01 aa 40 20061014
id xm je bh
01 aa 23 20061012
01 aa 30 20061013
01 aa -23 20061012
01 aa 40 20061014现在这些记录中je和的值一个是正23一个是负23而bh是一致的
怎样能得到下面的结果
id xm je bh
01 aa 30 20061013
01 aa 40 20061014
where bh not in
(
select bh from (你写的select语句) a
group by bh
having sum(je)<>0
)
t.*
from
表 t
where
not exists(select 1 from 表 where bh=t.bh and je=-t.je)
d.szdm csfxmbm,substring(d.fymc,0,10) csfxm,
substring(a.cfbh,3,12) ccfh,b.fyrq dfy,a.fysl
from my_data.dbo.zysf_zyfymx a,my_data.dbo.ch_zyyf_zycfzb b,my_data.dbo.zysf_zydj c,
my_data.dbo.sys_kjsfxm d
where a.cfbh=b.cfbh and a.zyh=c.zyh and a.fydm=d.fydm and
a.zyh='0103200609050135' and a.cfbh<>''
where bh not in
(
select bh from (你写的select语句) a
group by bh
having sum(je)<>0
)
t.*
from
表 t
where
not exists(select 1 from 表 where bh=t.bh and je=-t.je)