Db2 Window Functions

This section provides you with the most commonly used Db2 window functions.

NameDescription
CUME_DISTReturn the cumulative distribution of a row in a set of rows
DENSE_RANKReturn the rank of a row in an ordered set of rows with no gaps in rank values.
FIRST_VALUEAccess the value from the first row in a specified window frame.
LAGAccess to a row at a given physical offset that comes before the current row without using a self-join.
LAST_VALUEGet the value of the last row in a specified window frame.
LEADAccess to the row at a given physical offset that follows the current row.
NTH_VALUEAccess to the value of the Nth row in a set of rows.
NTILEDistribute an ordered set of rows to a number of buckets and assign a bucket number to each row.
PERCENT_RANKReturn the percent rank of a row in a set of rows.
RANKReturn the rank of a row in a set of rows
ROW_NUMBERAssign a unique sequential integer starting from one to each row in a window partition
Was this tutorial helpful ?