Your question is Measure Week-Over-Week Metric Changes. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given weekly operational performance data for a delivery marketplace. Write a PostgreSQL query that compares each week's metric to the prior week for the same metric and returns the absolute change and percentage change. Use a window function such as LAG or LEAD to measure the shift over time.
| Column | Type | Description |
|---|---|---|
| metric_date | DATE | Week-ending date for the metric snapshot |
| metric_name | VARCHAR(100) | Name of the operational metric |
| metric_value | NUMERIC(12,2) | Measured value for that week |