Finance needs a revenue growth analysis showing monthly revenue alongside the previous month and the percentage growth rate. This helps identify seasonal trends and revenue acceleration.
| Column | Type |
|---|---|
| InvoiceId | INTEGER (Primary Key) |
| CustomerId | INTEGER (Foreign Key → Customer.CustomerId) |
| InvoiceDate | TIMESTAMP |
| BillingAddress | TEXT |
| BillingCity | TEXT |
| BillingState | TEXT |
| BillingCountry | TEXT |
| BillingPostalCode | TEXT |
| Total | NUMERIC(10,2) |
TO_CHAR(InvoiceDate, 'YYYY-MM')LAG() to get the previous month's revenueGrowthRate as percentage change (NULL for first month)Month, Revenue, PrevMonthRevenue, GrowthRateReady to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.
Run your code to see the result here.