Aggregates Aggregate

nth_value()

Arguments & returns

nth_value(col0, col1)

Aggregate
Overload link col0col1 Returns
#01 TBIGINT T

In other engines

Oraclenth_value()

SELECT NTH_VALUE(x, 2) FROM LAST OVER (ORDER BY y) AS c FROM t
In Haybarn
SELECT NTH_VALUE(x, 2) OVER (ORDER BY y) AS c FROM t

SQLGlot example ↗

Snowflakenth_value()

SELECT NTH_VALUE(is_deleted, 2) OVER (PARTITION BY id) AS nth_is_deleted FROM my_table
In Haybarn
SELECT NTH_VALUE(is_deleted, 2) OVER (PARTITION BY id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS nth_is_deleted FROM my_table

SQLGlot example ↗