Events per million residents
Advancedmulti-table JOINEarthquakes (USGS, Oct 2026)
For states with at least 5 matched events (as in the previous exercise), return name, event count and events per million residents (pop2024), rounded to 2 decimals. Sort by the rate, highest first.
Solution
WITH per_state AS (
SELECT s.name, COUNT(*) AS n
FROM quakes q
JOIN state_abbrev s
ON q.place LIKE '%, ' || s.abbrev OR q.place LIKE '%, ' || s.name
GROUP BY s.name
HAVING COUNT(*) >= 5
)
SELECT p.name, ps.n, ROUND(ps.n * 1000000.0 / p.pop2024, 2) AS per_million
FROM per_state ps
JOIN state_population p ON p.name = ps.name AND p.sumlev = '040'
ORDER BY per_million DESC;Expected output:
Hint
Build the per-state counts in a CTE, then join to state_population on name (state rows only).
Same question in Excel / Google Sheets
Build the per-state counts (previous exercise), XLOOKUP pop2024 by name, divide.
Download the CSV from the datasets page. Column letters assume the CSV opens with its header in row 1.
Tip: Ctrl+Enter (⌘+Enter on Mac) checks your answer. Everything runs in your browser; nothing you type is sent anywhere.