Write a SQL query using window functions to rank security alerts by severity within each host and return the top alert per host at ReliaQuest.
Use the security_alerts table. Exclude alerts without a host. For equal severities, select the alert with the lower alert_id.
host_id, alert_id, severity, alert_type, and severity_rank.alert_id.host_id ascending.| Column | Type | Description |
|---|---|---|
| alert_idPK | INT | Unique identifier for the security alert |
| host_id | VARCHAR(50) | Host associated with the alert |
| severity | INT | Alert severity score, where higher values indicate greater severity |
| alert_type | VARCHAR(100) | Classification of the security alert |
| status | VARCHAR(30) | Current handling status of the alert |