Write a complex SQL query utilizing window functions to rank transaction volumes per trader over a monthly period.
Use the provided trader, transaction, and trading venue tables. Include executed transactions from January through March 2025, excluding non-positive quantities, inactive venues, unmatched traders, and transactions without a venue.
Output
- One row per trader and month, with
month_start, trader_id, trader_name, total_volume, transaction_count, total_notional, volume_rank, previous_month_volume, and volume_share_pct.
- Rank ties equally by descending total volume. Use
NULL when a trader has no prior month.
- Order by month, rank, and trader ID.