SQL QuestSQL Interview Questions › Aggregation & Grouping

Failure Clustering — State + Year

MediumFreeQuerying BasicsAggregation & GroupingDate Functions

Regional failure waves — bank failures cluster in time and place: Texas savings & loan crisis 1980s, Florida real-estate bust 2008-2010, regional bank crisis 2023 (SVB, Signature, First Republic, all California/New York). Cluster failures by (state, year) and find groups where 3 or more banks failed in the same state in the same year — the post-crisis pattern. Show state, failure_year, failure_count, total_pre_failure_assets. Order by failure_count desc, then failure_year desc. Top 10. (failure_date is text in M/D/YYYY format — extract year via SUBSTR last 4 chars.)

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

failures

certnamecitystatefailure_datepre_failure_assetspre_failure_depositsresolution_typeestimated_loss
57488METROPOLITAN CAPITAL B&TCHICAGONULL1/30/2026261185212152FAILURENULL
5520SANTA ANNA NATIONAL BANKSANTA ANNANULL6/27/20257693871376FAILURE23460
28611PULASKI SAVINGS BANKCHICAGONULL1/17/20254946642741FAILURE30284

Expected output: Hot zones of bank failure

Hint

CAST(SUBSTR(failure_date, -4) AS INTEGER) extracts year from M/D/YYYY. Skip failure_date that's NULL or '0'.

Concepts

SELECT GROUP BY HAVING Date Functions

Practise the topic: SQL practice questions · GROUP BY exercises · Date function practice

In these company practice sets

Morgan Stanley

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Class Survival BreakdownMedium · FreeDepartment Roster with GROUP_CONCATMedium · FreeMovie Rating Tier BreakdownMedium · FreeFull Survival Dashboard by ClassMedium · FreeGenre Financial ReportMedium · FreeDepartment Compensation ReportMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test