oracle 正负抵消记录?
dydh je
XSTH1001260002 1950
XSTH1001260002 -1950
XSTH1001260005 567
想要的结果 XSTH1001260005 567
XSTH1001260002 两条记录抵消
请大家帮帮写一下
------解决方案--------------------select * from table where dydh not in(
select t.dydh
from table t
group by t.dydh
);
------解决方案--------------------针对你的数据可以这样……
SQL code
select * from
(select dydh,sum(je) je from tb group by dydh)
where je <> 0
------解决方案--------------------
select * from test where dydh in (
select dydh from test group by dydh having sum(je)<>0)