Data Cleaning Reps

← All exercises

Match earthquakes to US states

AdvancedJOIN on messy keysEarthquakes (USGS, Oct 2026)

Places end in either a state name (, Alaska) or a code (, CA). Join quakes to state_abbrev to count events per state name, catching both forms. Return state name and count, largest first, then name A→Z.

Hint

Join ON q.place LIKE '%, ' || s.abbrev OR q.place LIKE '%, ' || s.name.

Same question in Excel / Google Sheets

Helper column with the text after the last comma, map codes to names with XLOOKUP against state_abbrev, then pivot.

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.

← Fastest growth 2020→2024Events per million residents →