Events per type
BeginnerGROUP BYEarthquakes (USGS, Oct 2026)
For each type, return the type and how many rows have it. Sort by the count, largest first.
Solution
SELECT type, COUNT(*) AS n
FROM quakes
GROUP BY type
ORDER BY n DESC;Expected output:
Hint
GROUP BY type, COUNT(*), ORDER BY the count.
Stuck? Read Guide 4 — GROUP BY and CASE.
Same question in Excel / Google Sheets
Insert → PivotTable: type in Rows, Count of id in Values. Or, in Excel 365 / Google Sheets: =UNIQUE(K2:K2629) in a free column (for example R) and =COUNTIF(K:K,R2) beside each unique type. Follows Google's documented syntax; not tested in Sheets.
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.