How would you write a SQL query to find trends using window functions over time for Eurofins data?
Use the provided Eurofins laboratory, service-line, and test-order data. Include completed orders from 2025 and show trends for each service line, including months where revenue may be NULL.
service_line_name, month, test_count, monthly_revenue, previous_month_revenue, mom_revenue_pct, cumulative_tests, and rolling_3_month_avg.| Column | Type | Description |
|---|---|---|
| laboratory_idPK | INT | Unique laboratory identifier |
| laboratory_name | VARCHAR(100) | Eurofins laboratory name |
| country | VARCHAR(60) | Country where the laboratory operates |
| Column | Type | Description |
|---|---|---|
| service_line_idPK | INT | Unique service-line identifier |
| service_line_name | VARCHAR(80) | Eurofins testing service line |
| service_group | VARCHAR(80) | Higher-level service grouping |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique test order identifier |
| laboratory_id | INT | Laboratory processing the order |
| service_line_id | INT | Service line associated with the order |
| completed_at | TIMESTAMP | Timestamp when testing was completed |
| status | VARCHAR(30) | Order processing status |
| revenue | NUMERIC(12,2) | Revenue associated with the order |