LEAD brings the next row alongside
Starting table: cafe_sales
| month | sales |
|---|---|
| 2026-01 | 120 |
| 2026-02 | 150 |
| 2026-03 | 140 |
LEAD reads a value from the next row in the order you put inside OVER. It lets Rowan compare each month's sales with the next recorded month while keeping every row. The last row has no next row, so its next value is NULL. Like LAG, LEAD follows recorded rows: it does not fill missing months or predict future sales.
A tiny example
In plain English: Show me each month’s sales next to the sales from the month that follows.
SELECT month, sales, LEAD(sales) OVER (ORDER BY month) AS next
FROM cafe_sales
ORDER BY month;Query result
| month | sales | next |
|---|---|---|
| 2026-01 | 120 | 150 |
| 2026-02 | 150 | 140 |
| 2026-03 | 140 | NULL |
January sees February's 150; February sees March's 140. March has no next recorded row.
Related SQL lessons
Ready for a break?
A fresh, bite-sized SQL puzzle waits every morning. Tap tiles, see real results. No terminal, no setup, no timers.
Try today's free SQL puzzle