LAG and LEAD for Sequential Comparison
Hard
window-functions
Two Sigma
Uber
Amazon
Write a query using LAG() and LEAD() to show each month's revenue alongside the previous and next month's revenue. Return month, revenue, prev_month_revenue, and next_month_revenue, ordered by month.
Expected Output: Monthly revenue with previous and next month context.
Tables
Hints (3 available)
SQL Editor
Output
Click "Run" to see results...