SQL · Pattern 10 — Window Functions
LEAD()
Accesses the next row.
Source data — Pattern 10: Window Functions
All queries run against the shared employees table (see schema.sql). This pattern introduces a sales table to demonstrate window functions including ranking, navigation, running totals, moving averages and window aggregates.


What it does
Accesses the next row.
Problem
Display the next month's sales.
SELECT *,
LEAD(sales_amount) OVER(ORDER BY sale_month) AS result
FROM sales;
Result
