SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual—523725-004
9-7
Sequence Functions
Sequence Functions
Sequence functions operate on ordered rows of the intermediate result table of a 
SELECT statement that includes a SEQUENCE BY clause. Sequence functions are 
categorized generally as difference, moving, offset, or running. 
Difference sequence functions:
DIFF1 Function
 on 
page 9-49
Calculates differences between values of a column expression 
in the current row and previous rows.
DIFF2 Function
 on 
page 9-52
Calculates differences between values of the result of DIFF1of 
the current row and DIFF1 of previous rows.
Moving sequence functions:
MOVINGAVG Function
 on 
page 9-87
Returns the average of nonnull values of a column expression 
in the current window.
MOVINGCOUNT 
Function on page 9-89
Returns the number of nonnull values of a column expression 
in the current window.
MOVINGMAX Function
on page 9-91
Returns the maximum of nonnull values of a column expression 
in the current window.
MOVINGMIN Function
 on 
page 9-93
Returns the minimum of nonnull values of a column expression 
in the current window.
MOVINGSTDDEV 
Function on page 9-95
Returns the standard deviation of nonnull values of a column 
expression in the current window.
MOVINGSUM Function
on page 9-97
Returns the sum of nonnull values of a column expression in 
the current window.
MOVINGVARIANCE 
Function on page 9-99
Returns the variance of nonnull values of a column expression 
in the current window.
Offset sequence function:
OFFSET Function
 on 
page 9-102
Retrieves columns from previous rows.
Running sequence functions:
RUNNINGAVG Function
on page 9-126
Returns the average of nonnull values of a column expression 
up to and including the current row.
RUNNINGCOUNT 
Function on page 9-128
Returns the number of rows up to and including the current row.
RUNNINGMAX Function
on page 9-130
Returns the maximum of values of a column expression up to 
and including the current row.
RUNNINGMIN Function
on page 9-132
Returns the minimum of values of a column expression up to 
and including the current row.
RUNNINGSTDDEV 
Function on page 9-134
Returns the standard deviation of nonnull values of a column 
expression up to and including the current row.










