Write a SQL query to compare current-period metrics against prior-period metrics using window functions.
Use the provided reporting periods and metric observations. Compare each observation with the preceding available period for the same desk.
desk_name, period_name, current_metric, prior_metric, and metric_change| Column | Type | Description |
|---|---|---|
| period_idPK | INT | Unique reporting-period identifier |
| period_name | VARCHAR(20) | Readable reporting-period label |
| period_start | DATE | Start date used for chronological ordering |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique metric observation identifier |
| desk_name | VARCHAR(40) | Desk associated with the observation |
| period_id | INT | Referenced reporting period |
| metric_value | DECIMAL(12,2) | Metric value for the desk and period |