PostgreSQLWindow FunctionsLEAD
LAG

LEADWindow Functions

FIRST_VALUE

Returns the value from n rows after the current row.

Syntax

LEAD(expr [, n [, default]]) OVER (w)

Example

Enter values below to update the example in real time.

order_month
revenue
next_month_revenue
monthly_sales
SELECT order_month, revenue,
       LEAD(revenue) OVER (ORDER BY order_month) AS next_month_revenue
FROM monthly_sales;