Your question is SQL Rolling Average With Spikes. 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.
Point72's trading analytics team wants to monitor unusual daily activity by ticker. Write a PostgreSQL query that aggregates trade volume by ticker and trading date, then compares each day with the prior seven completed trading observations.
trades to active securities only and aggregate total volume per ticker and date.false when the baseline is not yet available.| Column | Type | Description |
|---|---|---|
| trade_idPK | INT | Unique trade identifier |
| ticker | VARCHAR(10) | Ticker symbol referenced by securities |
| trade_date | DATE | Date on which the trade occurred |
| volume | INT | Number of shares traded |
| Column | Type | Description |
|---|---|---|
| tickerPK | VARCHAR(10) | Security ticker symbol |
| security_name | VARCHAR(100) | Security display name |
| is_active | BOOLEAN | Whether the security is actively monitored |