runningDifference
Calculates the difference between successive row values ββin the data block. Returns 0 for the first row and the difference from the previous row for each subsequent row.
Syntaxβ
runningDifference(expression)
Argumentsβ
Arguments | Description |
---|---|
expression | Any expression which generates numberic result, including integer numbers, real numbers, date and datetime. |
Return Typeβ
Numberic Type
Examplesβ
databend :) DESC runing_difference_test;
ββFieldββ¬βTypeβββ¬βNullββ
β a β UInt8 β NO β
βββββββββ΄ββββββββ΄βββββββ
databend :) SELECT * FROM runing_difference_test;
βββaββ
β 1 β
β 3 β
β 5 β
β 10 β
ββββββ
βββaββ
β 15 β
β 20 β
ββββββ
databend :) SELECT runningDifference(a) FROM runing_difference_test;
ββrunningDifference(a)ββ
β 0 β
β 2 β
β 2 β
β 5 β
ββββββββββββββββββββββββ
ββrunningDifference(a)ββ
β 0 β
β 5 β
ββββββββββββββββββββββββ