select
sum(b.yljyht) as yljyht ,
sum(b.yljylb) as yljylb ,
a.BZ
from
qq a,
qq b
where
b.htlh=a.htlh and b.lblh=a.lblh and b.jlr<=a.jlr and b.xxx<=a.xxx
group by
a.BZ
sum(b.yljyht) as yljyht ,
sum(b.yljylb) as yljylb ,
a.BZ
from
qq a,
qq b
where
b.htlh=a.htlh and b.lblh=a.lblh and b.jlr<=a.jlr and b.xxx<=a.xxx
group by
a.BZ
t.yljyht ,
t.yljylb ,
a.BZ
FROM qq a,(select htlh,lblh,jlr,xxx,sum(yljyht) as yljyht,sum(yljylb) as yljylb
from qq group by htlh,lblh,jlr,xxx) as t
where a.htlh=t.htlh
and a.lblh=t.lblh
and a.jlr=t.jlr
and a.xxx=t.xxx
SELECT
a.HTLH,
lblh,
a.JLR,
a.HTNGJ3,
a.HTZJ1,
a.HTJJ2,
a.HTRKZ,
a.lbrkz,
a.HTCK,
a.lbckz,
(select sum(yljyht) from qq where htlh=a.htlh and lblh=a.lblh and jlr<=a.jlr and xxx<=a.xxx ) as yljyht ,
(select sum(yljylb) from qq where htlh=a.htlh and lblh=a.lblh and jlr<=a.jlr and xxx<=a.xxx ) as yljylb ,
a.BZ
FROM qq a其中只有xxx是不重复的,其他都有重复