Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
LEAD and LAG
FIRST_VALUE, LAST_VALUE, NTH_VALUE
Summary
25. Summary

Instruction

Excellent!! That's all we wanted to teach you today. Let's review what we've learned:

  • LEAD(x) and LAG(x) give you the next/previous value in the column x, respectively.
  • LEAD(x,y) and LAG(x,y) give you the value in the column x of the row which is y rows after/before the current row, respectively.
  • FIRST_VALUE(x) and LAST_VALUE(x) give you the first and last value in the column x, respectively.
  • NTH_VALUE(x,n) gives you the value in the column x of the n-th row.
  • LAST_VALUE and NTH_VALUE usually require the window frame to be set to ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.

Now, are you ready for a short quiz?

Exercise

Click Next exercise to start.