SQL: Analytic Function LAG and LEAD
In this video, we will see analytic function LAG and LEAD with a problem statement.
SQL queries:
select c.*,
LAG( revenue, 1, 0) over ( partition by name order by year) previous_revenue,
LEAD(revenue, 1, 0) over ( partition by name order by year ) next_revenue
from company_revenue c