LEAD()
LEAD() is a SQL function in the Window Functions category. Accesses data from a following row within the result set. Opposite of LAG. The syntax is LEAD(column, offset, default) OVER (ORDER BY column). It accepts column, offset, default. It returns value from next row. A typical example: SELECT date, revenue, LEAD(revenue) OVER (ORDER BY date) AS next_day_revenue FROM daily_sales; -- Next day's revenue, useful for forecasting A close relative is ROW_NUMBER(), which assigns a unique sequential integer to each row within its partition (1, 2, 3...). A close relative is RANK(), which similar to ROW_NUMBER but gives the same rank to equal values. Leaves gaps in ranking. A close relative is DENSE_RANK(), which like RANK but without gaps. Equal values get the same rank, and the next number follows sequentially. More about this category: Window/analytical functions — ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, NTILE. Related Window Functions entries: ROW_NUMBER(), RANK(), DENSE_RANK(), LAG(), NTILE(), SUM() OVER, COUNT() OVER, AVG() OVER.