Considerations For Rows Since; Counting The Rows; Examples Of Rows Since - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

ROWS SINCE [INCLUSIVE] (condition [,max-rows])
INCLUSIVE
specifies the current row is to be considered. If you specify INCLUSIVE, the condition is
evaluated in the current row. Otherwise, the condition is evaluated beginning with the
previous row. If you specify INCLUSIVE and the condition is true in the current row, ROWS
SINCE returns 0.
condition
specifies a condition to be considered for each row in the result table. Each column in
condition must be a column that exists in the result table. If the condition has never been
true for the result table, ROWS SINCE returns null.
max-rows
is an SQL numeric value expression of signed data type SMALLINT or INTEGER that specifies
the maximum number of rows from the current row to consider. If the condition has never
been true for max-rows from the current row, or if max-rows is negative or null, ROWS
SINCE returns null.

Considerations for ROWS SINCE

Counting the Rows

If you specify INCLUSIVE, the condition in each row of the result table is evaluated starting with
the current row as row 0 (zero) (up to the maximum number of rows or the size of the result
table). Otherwise, the condition is evaluated starting with the previous row as row 1.
If a row is reached where the condition is true, ROWS SINCE returns the number of rows counted
so far. Otherwise, if the condition is never true within the result table being considered, ROWS
SINCE returns null. Neoview SQL then goes to the next row as the new current row.

Examples of ROWS SINCE

Return the number of rows since the condition I1 IS NULL became true:
SELECT ROWS SINCE (I1 IS NULL) AS ROWS_SINCE_NULL
FROM mining.seqfcn
SEQUENCE BY TS;
ROWS_SINCE_NULL
---------------
--- 5 row(s) selected.
Return the number of rows since the condition I1 < I2 became true:
SELECT ROWS SINCE (I1<I2), ROWS SINCE INCLUSIVE (I1<I2)
FROM mining.seqfcn
SEQUENCE BY TS;
(EXPR)
---------------
?
?
1
2
1
(EXPR)
---------------
?
0
1
1
2
0
1
1
2
0
ROWS SINCE Function
393

Advertisement

Table of Contents
loading

Table of Contents