SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-127
Examples of RUNNINGCOUNT
The table SEQFCN has columns I1 and TS with data that is sequenced by column TS:
Return the number of rows up to and including the current row:
SELECT RUNNINGCOUNT (*) AS COUNT_ROWS
FROM mining.seqfcn
SEQUENCE BY TS;
COUNT_ROWS
------------
1
2
3
4
5
--- 5 row(s) selected.
Return the number of rows that include nonnull values of I1 up to and including the
current row:
SELECT RUNNINGCOUNT (I1) AS COUNT_I1
FROM mining.seqfcn
SEQUENCE BY TS;
COUNT_I1
------------
1
2
2
3
4
--- 5 row(s) selected.
I1 TS
6215 TIMESTAMP '1950-03-05 08:32:09'
28174 TIMESTAMP '1951-02-15 14:35:49'
null TIMESTAMP '1955-05-18 08:40:10'
4597 TIMESTAMP '1960-09-19 14:40:39'
11966 TIMESTAMP '1964-05-01 16:41:02'