Your question is SQL Rolling Averages and Anomalies. Start with the requirements and the two tables 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.
S&P Global teams monitor product-level financial metrics across platforms such as Capital IQ and Market Intelligence. Write a PostgreSQL query that calculates a trailing three-observation average and flags unusually large fluctuations.
financial_metrics to spg_products and include only active products with non-null metric values.metric_date.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | S&P Global product name |
| is_active | BOOLEAN | Whether the product is monitored |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique metric observation identifier |
| product_id | INT | Referenced product identifier |
| metric_date | DATE | Date of the observation |
| metric_value | DECIMAL(14,2) | Observed financial metric value |