Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
LEAD() and LAG()
6. LEAD(x) – practice
FIRST_VALUE(), LAST_VALUE()
Summary

Instruction

Cool! Note that the column specified as the argument of LEAD() may be different than the column by which we sort rows:

SELECT
  Name,
  OpenDate,
  Budget,
  LEAD(Budget) OVER(ORDER BY OpenDate ASC) AS Lead
FROM Website;

The above query will still sort the rows by the opening date, but will show the Budget of the next website instead of its opening date.

Now it's your turn to write a query with LEAD(x).

Exercise

For all the statistics of the website with Id = 1, show the Day, the number of users and the number of users on the next day. Name the column Lead.

Stuck? Here's a hint!

Use LEAD(Users) and remember about specifying the proper ORDER BY.