Your question is Rolling 30-Day Trading Volumes. 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.
Nasdaq Trade Management needs account-level activity metrics for monitoring trading behavior. Write a PostgreSQL query that calculates rolling 30-day trading volume for active accounts.
status = 'ACTIVE'.daily_volume.rolling_30_day_volume as the sum from the current trade date and the preceding 29 calendar days, partitioned by account.account_id and trade_date.| Column | Type | Description |
|---|---|---|
| account_idPK | INTEGER | Unique trading account identifier |
| account_name | VARCHAR(100) | Account display name |
| status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| trade_idPK | INTEGER | Unique trade identifier |
| account_id | INTEGER | Account associated with the trade |
| trade_date | DATE | Calendar date of the trade |
| volume | NUMERIC(14,2) | Number of shares or contracts traded |