300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > oracle 中累加函数 oracle用sum函数实现累加

oracle 中累加函数 oracle用sum函数实现累加

时间:2022-01-09 09:37:52

相关推荐

oracle 中累加函数 oracle用sum函数实现累加

====================Question=========================

jmbdat dayt y mon

27-9月 -07 2033.2 09

28-9月 -07 2750.28 09

29-9月 -07 2885.68 09

30-9月 -07 2556.68 09

01-10月-07 2903.04 10

02-10月-07 1002.96 10

03-10月-07 1038.24 10

对上边的表用sql处理下 变成下面的

jmbdat dayt y mon mont

27-9月 -07 2033.2 09 2033.2

28-9月 -07 2750.28 09 4783.28

29-9月 -07 2885.68 09 7669.16

30-9月 -07 2556.68 09 5.84

01-10月-07 2903.04 10 2903.04

02-10月-07 1002.96 10 3906

03-10月-07 1038.24 10 4944.24

该怎么做啊?

==================Solution=========================

SQL:

select tt.*,

sum(tt.dayt) over (partition by tt.mon order by tt.jmbdat,tt.y,tt.mon) as sum_dayt

from tablename tt;

Result :

JMBDAT DAYT Y MON SUM_DAYT

----------- ---------- ---------- ------ ----------

-9-27 2033.2 09 2033.2

-9-28 2750.28 09 4783.48

-9-29 2885.68 09 7669.16

-9-30 2556.68 09 10225.84

-10-1 2903.04 10 2903.04

-10-2 1002.96 10 3906

-10-7 1038.24 10 4944.24

7 rows selected

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。