--取一条指定时间的数据
select max(name)KEEP (dense_rank FIRST ORDER BY no desc) from t
--依据PSL进行分摊
select sum(fhtj * decode(fft,
0,
0,
decode(fft / abs(fft),
1,
fsl,
decode(fsl + fft,
0,
0,
decode((fsl + fft) / abs(fsl + fft),
1,
fsl + fft,
0)))))
into cnt
from (SELECT FT,
fDj,
fsl,
sum(fsl) over(order by FId) fsumsl,
psl - sum(fsl) over(order by FId) fft
FROM T_GCHTLRBMX
where fzlh = p_fzlh);