Given a table of security events, write a query to calculate rolling thirty-day averages of threat detections per organization.
Treat event_type = 'threat_detection' as a threat detection. Calculate daily results for dates with events, exclude events without an organization, and use a calendar-based thirty-day window including the current date.
organization_id, event_date, daily_threat_detections, and rolling_30_day_averageorganization_id, then event_date| Column | Type | Description |
|---|---|---|
| event_idPK | INTEGER | Unique security event identifier |
| organization_id | INTEGER | Organization associated with the event |
| event_at | TIMESTAMP | Timestamp when the event occurred |
| event_type | VARCHAR(50) | Security event classification |
| source | VARCHAR(50) | System that generated the event |