select a.dd, a.bh, a.bz, b.je
from table a,
(select sum(nvl(a.je,0)) as je,max(rowid) as rowid from table b group by dd,bh,bz) b
where a.rowid(+) = b.rowid
order by dd,bh,bz
select dd,bh,bz,je,zh=case when (select count(1) from
(
select *,te=(select min(je) from t a where a.bh=b.bh)
from t b) a where a.dd=b.dd)>=2 and je=te then 0
else te end
from
(
select *,te=(select min(je) from t a where a.bh=b.bh)
from t b) b
select dd,bh,bz,decode(max(zh) over(partition by dd,bh,bz),zh,zh,0) zh from
(select dd,bh,bz,sum(je) over(partition by dd,bh,bz order by je) zh from tablename t)