Given a table of message delivery logs, write a query to identify the top three destination countries with the highest latency spikes over the past 48 hours.
Treat a latency spike as a delivery with latency_ms greater than 1000. Rank countries by their maximum spike latency, then by spike count and country code for deterministic tie-breaking.
country_code, spike_count, average_spike_latency_ms, and maximum_spike_latency_ms.| Column | Type | Description |
|---|---|---|
| log_idPK | BIGINT | Unique delivery log identifier |
| country_code | VARCHAR(2) | ISO destination country code |
| latency_ms | INTEGER | Message delivery latency in milliseconds |
| logged_at | TIMESTAMPTZ | Timestamp when the delivery log was recorded |