SQL: Monthly Revenue Growth
Medium
SQL — Window Functions
SQL
LAG
Growth
Calculate month-over-month revenue growth.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: month revenue
1 1000
2 1200
3 900
Output:
Example 2:
Input: month revenue
1 1000
2 1200
3 900
Output:
Hints
LAG window function.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console