LEAD
From Oracle FAQ
LEAD is a SQL analytical function that can makes data from leading (following) rows available without having to do a self join.
Example[edit]
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
Also see[edit]
- LAG, look at values of prior rows.
