Practice Interview Questions
| Question | Status |
|---|---|
Write a SQL query to calculate the month-over-month percentage change in revenue.
The output should include the year-month date (in YYYY-MM format) and percentage change, rounded to 2 decimal points.
purchases table:
| Column Name | Description |
|---|---|
| purchase_date | Date of the purchase |
| revenue | Revenue on that date |
| year_month | pct_change |
|---|---|
| 2022-01 | NULL |
| 2022-02 | 100.00 |
| 2022-03 | 50.00 |
| 2022-04 | -16.67 |
| 2022-05 | 60.00 |
Write a SQL query to calculate the month-over-month percentage change in revenue.
The output should include the year-month date (in YYYY-MM format) and percentage change, rounded to 2 decimal points.
purchases table:
| Column Name | Description |
|---|---|
| purchase_date | Date of the purchase |
| revenue | Revenue on that date |
| year_month | pct_change |
|---|---|
| 2022-01 | NULL |
| 2022-02 | 100.00 |
| 2022-03 | 50.00 |
| 2022-04 | -16.67 |
| 2022-05 | 60.00 |