Write a SQL query to calculate the average number of security incidents per customer by month. Use the customers and security_incidents tables. Include every customer in the monthly average, including customers with no incidents during that month. Ignore incidents without a valid customer or incident date.
month, formatted as YYYY-MM, and avg_incidents_per_customer.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(150) | Customer organization name |
| service_tier | VARCHAR(30) | Cloud Security Services subscription tier |
| Column | Type | Description |
|---|---|---|
| incident_idPK | INT | Unique security incident identifier |
| customer_id | INT | Customer associated with the incident |
| incident_date | TIMESTAMP | Timestamp when the incident was recorded |
| incident_type | VARCHAR(50) | Security incident classification |
| severity | VARCHAR(20) | Incident severity level |