skip to today's puzzle

LEAD brings the next row alongside

Starting table: cafe_sales

Starting cafe_sales data before the example query
monthsales
2026-01120
2026-02150
2026-03140

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

monthsalesnext
2026-01120150
2026-02150140
2026-03140NULL

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