From the course: Advanced SQL – Window Functions

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Offset window functions

Offset window functions - SQL Tutorial

From the course: Advanced SQL – Window Functions

Start my 1-month free trial

Offset window functions

- [Instructor] Offset window functions enable access to individual partition rows, and they come in two flavors. A pointer to another row can be either based on a current position or on an absolute position regardless of the current one. If you're looking for the restrooms, I can help you get there based on your current location. Move two doors eastward or 600 steps north from where you are. Alternatively, I can direct you to the same restrooms based on a known location. Two doors from the entrance or last door to the north, and this is regardless of your current position. Offset window functions support both direction types. Lead and lag are called row offset functions, as they use a positional offset from the current row. This is the equivalent of move two doors eastward. Partitioning is optional, and framing is irrelevant, as the offset is specified from the current row's position. First, last, and nth value functions are…

Contents