The below is the window function. When you need to analyze the data, it can use it.
Function |
Return Type |
Description |
row_number() |
bigint |
number of the current row within its partition, counting from 1 |
rank() |
bigint |
rank of the current row with gaps; same as row_number of its first peer |
dense_rank() |
bigint |
rank of the current row without gaps; this function counts peer groups |
percent_rank() |
double precision |
relative rank of the current row: (rank - 1) / (total rows - 1) |
cume_dist() |
double precision |
relative rank of the current row: (number of rows preceding or peer with current row) / (total rows) |
ntile(num_buckets integer) |
integer |
integer ranging from 1 to the argument value, dividing the partition as equally as possible |
lag(value anyelement [,offset integer [, defaultanyelement ]]) |
same type asvalue |
returns value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead returndefault (which must be of the same type as value). Both offset and default are evaluated with respect to the current row. If omitted, offsetdefaults to 1 and default to null |
lead(value anyelement [,offset integer [, defaultanyelement ]]) |
same type asvalue |
returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead returndefault (which must be of the same type as value). Both offset and default are evaluated with respect to the current row. If omitted, offsetdefaults to 1 and default to null |
first_value(value any) |
same type asvalue |
returns value evaluated at the row that is the first row of the window frame |
last_value(value any) |
same type asvalue |
returns value evaluated at the row that is the last row of the window frame |
nth_value(value any, nthinteger) |
same type asvalue |
returns value evaluated at the row tha |