sqlserver 里,如下图我想求 累计,感觉没错。。不知道错在哪里了
缺少 partition BY
select id,sum(sl) over(partition by '' order by id asc) from .............
---------------------------
------------------------
select *,(select sum(num_) from a b where a.id>=b.id) from a order by id asc
说实话 没搞懂你order by是干啥的,你要是根据id累计
直接
select id,sum(num) as 累计
from ...
group by id
order by id
根据id没必要开窗函数,你想实现啥?
你确定你是sqlserver吗