SQL QuestSQL Interview Questions › Aggregation & Grouping

States With 5 or More Banks

EasyFreeQuerying BasicsAggregation & Grouping

Among the top 200 banks, find states that host 5 or more headquarters. Show state and bank_count. Order by bank_count descending, then state. Use HAVING — these are the post-aggregation gates.

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

institutions

certnamecitystatezipcharter_classestablished_datetotal_assetstotal_depositstotal_equityoffice_countbank_class
628JPMorgan Chase Bank, National AssociationColumbusOH43240801/01/1824375266200026978420003359360005335N
3510Bank of America, National AssociationCharlotteNC282021304410/17/1904263682300021019680002462500003840N
7213Citibank, National AssociationSioux FallsSD57108146106/16/181218364360001465300000176530000958N

Expected output: States with concentrated banking presence

Hint

GROUP BY state HAVING COUNT(*) >= 5.

Concepts

SELECT GROUP BY HAVING Aggregation

Practise the topic: SQL practice questions · GROUP BY exercises

Related questions

Counting RowsEasy · FreeSUM, AVG, MIN, MAXEasy · FreeGROUP BY BasicsEasy · FreeMonthly Order CountEasy · FreeHow Many Genres Do We Cover? (DISTINCT)Easy · FreeFemale Survivor CountEasy · 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