|Oracle8i SQL Reference
Release 2 (8.1.6)
Functions, 37 of 121
For information on syntax and semantics, see "Analytic Functions".
LAG is an analytic function. It provides access to more than one row of a table at the same time without a self-join. Given a series of rows returned from a query and a position of the cursor,
LAG provides access to a row at a given physical offset prior to that position.
If you do not specify offset, its default is 1. The optional default value is returned if the offset goes beyond the scope of the window. If you do not specify default, its default value is null.
The following example provides, for each salesperson in the
EMP table, the salary of the employee hired just before: