SQLSQL
#45

Calculate Month-over-Month Growth with LAG() in SQL

MediumFlipkart
Interview Question #45
Asked at Flipkart

Given monthly revenue records, compute the month-over-month revenue percentage change: `((current - previous) / previous) * 100`, rounded to 2 decimal places.

Input Table: monthly_revenue
3 rows preview
revenue_monthrevenue
2026-01100000
2026-02125000
2026-03118750
Expected Output Structure3 rows
revenue_monthrevenueprev_revenuemom_growth_pct
2026-01100000NULLNULL
2026-0212500010000025
2026-03118750125000-5
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us