LEAD

From Oracle FAQ
Jump to: navigation, search

LEAD is a SQL analytical function that can makes data from leading (following) rows available without having to do a self join.

[edit] Example

SQL> SELECT c1 "Curr",
  2         LEAD(c1) OVER (ORDER BY id) "Next",
  3         c1 - LEAD(c1) OVER (ORDER BY id) "Diff"
  4    FROM t1;
      Curr       Next       Diff
---------- ---------- ----------
        40         45         -5
        45         35         10
        35         37         -2
        37

[edit] Also see

  • LAG, look at values of prior rows.