看不懂,这样的SQL能执行吗?
select zhth, yf, hkje
from (
select zhth, substr(hksj, 1, 6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj, 1, 6)
)
)
where yf <= a.yf and zhth = a.zhth) as hklj
from (
select zhth, yf, hkje
from (select zhth,substr(hksj,1,6) as yf,sum(hkje) as hkje
from t_htxx_hkxx
group by zhth,substr(hksj,1,6)
)
) a
select zhth, yf, hkje
from (
select zhth, substr(hksj, 1, 6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj, 1, 6)
)
)
where yf <= a.yf and zhth = a.zhth) as hklj
from (
select zhth, yf, hkje
from (select zhth,substr(hksj,1,6) as yf,sum(hkje) as hkje
from t_htxx_hkxx
group by zhth,substr(hksj,1,6)
)
) a
(select sum(hkje)
from (select zhth, yf, hkje
from (select zhth, substr(hksj,1,6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj,1,6)
)
)
where yf <= a.yf and zhth = a.zhth) as hklj
from (select zhth, yf, hkje
from (select zhth, substr(hksj,1,6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj,1,6)
)
) a
;
对不起贴子贴错了,上面的是要问的sql语句
这个语句在oracle8上可以执行,在oracle9 ora_00979 不是 group by 表达式
from (select zhth, yf, hkje
from (select zhth, substr(hksj,1,6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj,1,6)
)
) a ,
(select zhth, yf, hkje
from (select zhth, substr(hksj,1,6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj,1,6)
)
) b
where b.yf <= a.yf and b.zhth = a.zhth
sum?SELECT a.*, SUM(hkje)over(PARTITION BY zhth ORDER BY yf ) hkje_s
FROM (
select zhth, substr(hksj,1,6) as yf, sum(hkje) as hkje
from t_htxx_hkxx
group by zhth, substr(hksj,1,6)
) a