Your question is Rolling Window Genomic Orders. 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.
Tempus AI uses genomic test order data to monitor patient testing activity over time. Write a PostgreSQL query that calculates the rolling three-month average of completed genomic test orders for every patient.
patient_id, month_start, monthly_orders, and rolling_three_month_avg, ordered by patient and month.| Column | Type | Description |
|---|---|---|
| patient_idPK | INTEGER | Unique patient identifier |
| patient_name | VARCHAR(100) | Patient display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INTEGER | Unique genomic test order identifier |
| patient_id | INTEGER | Patient associated with the order |
| ordered_at | TIMESTAMP | Timestamp when the order was created |
| order_status | VARCHAR(20) | Current order status |