Compatible with PostgreSQL, Hologres allows you to use standard PostgreSQL syntax for data development.

The following table describes the window functions supported by Hologres. The functions supported by Hologres are only a subset of the PostgreSQL functions. For more information about how to use these functions, see Window Functions in the PostgreSQL documentation.
Function Description Example Result
row_number() Returns the ordinal number of the current row in a partition.
Note The ordinal number counts from 1.
row_number() over (order by c1) c1 | row_number ----+------------ a | 1 a | 2 b | 3 c | 4(4 rows)
rank() Returns the rank of the current row in a partition.
Note This function adds the number of tied rows to the tied rank to calculate the next rank. Therefore, the ranks may not be consecutive numbers.
rank() over (order by c1) c1 | rank ----+------ a | 1 a | 1 b | 3 c | 4(4 rows)
dense_rank() Returns the rank of the current row in a partition.
Note This function assigns consecutive ranks.
dense_rank() over (order by c1) c1 | dense_rank ----+------------ a | 1 a | 1 b | 2 c | 3(4 rows)
percent_rank() Calculates the percent rank of a row in a partition. The percent rank is determined by using this formula: `(Rank of the current row - 1)/(Total number of rows in the partition - 1)`. percent_rank() over (order by c1) c1 | percent_rank ----+------------------- a | 0 a | 0 b | 0.666666666666667 c | 1(4 rows)
lag() Returns the values for a row at a given offset before the current row in a partition.
Note The default value is returned if the current row does not have a preceding row at the given offset.
c1, lag(c1) over (order by c1) c1 | lag ----+----- a | a | a b | a c | b(4 rows)
lead() Returns the values for a row at a given offset after the current row in a partition.
Note The default value is returned if the current row does not have a following row at the given offset.
c1, lead(c1) over (order by c1) c1 | lead ----+------ a | a a | b b | c c | (4 rows)
first_value() Returns the value of the specified expression with respect to the first row in the window frame. c1, first_value(c1) over (order by c1) c1 | first_value ----+------------- a | a a | a b | a c | a(4 rows)
last_value() Returns the value of the specified expression with respect to the last row in the window frame. c1, last_value(c1) over (order by c1) c1 | last_value ----+------------ a | a a | a b | b c | c(4 rows)