赞
踩
代码如下:
select xmdc001,
xmdc015,
sum(xmdc015) over( order by xmdc001) as sum
from xmdc_t
代码说明:先按照xmdc001排序,然后累计xmdc015字段。譬如按产品排序,然后对销售的金额进行累加。
效果如下:
另外,以下代码含义为,先按照xmdc001排序分类,后进行累加。(注意,累加只会对相同的xmdc001进行累加)
select xmdc001,
xmdc015,
sum(xmdc015) over(partition by xmdc001 order by xmdc001) as sum
from xmdc_t
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。