Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The output should be the last column (Cum_Sal).

(输出应为最后一列(Cum_Sal)。)

 EMPLOYEE   MONTH   YEAR    SALARY Cum_Sal
 A            JAN   2016    2000     2000
 A            FEB   2016    2000     4000
 A            MAR   2016    2000     6000
 A            APR   2016    3000     9000
 A            MAY   2016    3000     12000
 A            JUN   2016    3000     15000
 A            JUL   2016    3000     18000
 A            AUG   2016    3000      .
 A            SEP   2016    3000       .
 A            OCT   2016    3000
 A            NOV   2016    3000
 A            DEC   2016    3000
 A            JAN   2017    3000     3000
 A            FEB   2017    3000     6000
 A            MAR   2017    3000     9000
 A            APR   2017    5000      .
 A            MAY   2017    5000       . (SO ON)
 A            JUN   2017    5000
 A            JUL   2017    5000
 A            AUG   2017    5000

Thanks for your help.

(谢谢你的帮助。)

SM

(SM)

  ask by Swadhin Mallik translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
375 views
Welcome To Ask or Share your Answers For Others

1 Answer

I am not sure the below query is perfect or not , but this solution helps you to find out the correct solution !

(我不确定以下查询是否完美,但是此解决方案可帮助您找到正确的解决方案!)

select
    EMPLOYEE, MONTH, YEAR ,SALARY ,sum(SALARY) over(order by EMPLOYEE) as Cum_Sal
from emp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...