PL/SQL Lead
Oracle PL/SQL Lead Function
The Lead function returns values from the next row in the table.
The Lead Function syntax:
lead ( exp [, offset [, default] ] )
over ( [ query_partition_clause ] order_by_clause )
Example:
Select job_id, start_date, lead (start_date,1) over (ORDER BY start_date) AS next_start_date From employee Where job_id = 3500;
Job_Id | Start_Date | Next_Start_Date |
3500 | 20/02/2008 | 22/02/2008 |
3500 | 22/02/2008 | 23/02/2008 |
3500 | 23/02/2008 | NULL |