Topic: Difference of values in lines on a condition
Kind night, dear participants of a forum!
Help to solve a problem as sorted out, apparently, almost all variants, but decisions and did not find. There is a following data structure. Total lines (where V2, V3 = null) are received by means of window analytic function. RW - a column for sorting of values that total lines were under groups which they sum up.
The task in the following:
To deduce in an additional column (only in total row) a difference between current and previous value (on column V5). For the second total row it will be 52.7 - 80.15, for the first or null or it is possible to receive 0 (80.15 - 80.15). Not total lines should be null.
"The live" example laid out here: http://www.sqlfiddle.com/#!4/197a0c/1/0
I will be grateful as for the real help in request change, and for any reasons about it.