Diff2 Function; Considerations For Diff2; Examples Of Diff2 - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

DIFF2 Function

"Considerations for DIFF2"

"Examples of DIFF2"

The DIFF2 function is a sequence function that calculates the amount of change in a DIFF1 value
from row to row in an intermediate result table ordered by a SEQUENCE BY clause in a SELECT
statement. See
DIFF2 is a Neoview SQL extension.
DIFF2 (column-expression-a [,column-expression-b])
column-expression-a
specifies a derived column determined by the evaluation of the column expression. If you
specify only one column as an argument, DIFF2 returns the difference between the value of
DIFF1(column-expression-a) in the current row and the same result in the previous row.
column-expression-b
specifies a derived column determined by the evaluation of the column expression. If you
specify two columns as arguments, DIFF2 returns the difference in consecutive values of
DIFF1(column-expression-a) divided by the difference in consecutive values in
column-expression-b.
See
"DIFF1 Function" (page
Considerations for DIFF2
Equivalent Result
If you specify one argument, the result of DIFF2 is equivalent to:
DIFF1(column-expression-a)- OFFSET(DIFF1(column-expression-a),1)
If you specify two arguments, the result of DIFF2 is equivalent to:
DIFF2(column-expression-a) / DIFF1(column-expression-b)
The two-argument version involves division by the result of the DIFF1 function. To avoid
divide-by-zero errors, make sure that column-expression-b does not contain any duplicate
values whose DIFF1 computation could result in a divisor of zero.
Datetime Arguments
In general, Neoview SQL does not allow division by a value of INTERVAL data type. However,
to permit use of the two-argument version of DIFF2 with times and dates, Neoview SQL relaxes
this restriction and allows division by a value of INTERVAL data type.
Examples of DIFF2
Retrieve the difference between the value of DIFF1(I1) in the current row and the same result
in the previous row:
SELECT DIFF2 (I1) AS DIFF2_I1
FROM mining.seqfcn
SEQUENCE BY TS;
DIFF2_I1
--------------------
--- 5 row(s) selected.
398
SQL Functions and Expressions
"SEQUENCE BY Clause" (page
396).
?
?
-31075
-5345
21830
326).

Advertisement

Table of Contents
loading

Table of Contents