MSD's research operations team needs a monthly view of completed experimental throughput for active programs. Write a PostgreSQL query that aggregates throughput by experiment date, then calculates cumulative and short-term throughput trends within each calendar month.
Requirements
- Join
throughput_events to experiments and include only active experiments, completed runs, and nonnegative or NULL throughput values from January and February 2025.
- Aggregate throughput by event date and month, treating NULL throughput as zero.
- Use window functions partitioned by month to calculate a running total and a three-reported-day moving average, ordered chronologically.
- Return one row per reported date, ordered by month and event date.
Output details
- Return columns in this order:
month, event_date, daily_throughput, running_total, moving_average_3_days.
- Filter
event_date inclusively from DATE '2025-01-01' through exclusively before DATE '2025-03-01'.
- Round
moving_average_3_days to exactly 4 decimal places.