SQL Language (MOSC)

MOSC Banner

Create “Select” statement with calculated column from previous row

in SQL Language (MOSC) 2 commentsAnswered ✓

Hello,

 

I have the following dates:

 

Row-No.         Qty     Total

1               -11        39

2               -9         30

3               10         40

4               -1         39

5               -2         37

6               -2         35

7               5          40

.....

.....

 

 

In the first line for calculating value in the "Total" column (39), we add the value from column "Qty" (-11) to the value from a DB function "get_act_value" (value = 50) --> (50+(-11)= 39).

 

Then from the second line to calculate the value in the "Total" column, we take the value in this column in the previous line and add the value from current column "Qty". (For Line 2: 39(from previous row) + (-9) = 30, and so on).

 

Is there a possibility to output this logic as a Sql statement?

 

Thanks

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center