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, NTH_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,
  opened,
  budget,
  LEAD(budget) OVER(ORDER BY opened)
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.

Stuck? Here's a hint!

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