SQL QuestSQL Interview Questions › Conditional Logic

Trust and Savings Banks

MediumFreeQuerying BasicsConditional LogicAggregation & GroupingString Functions

Banking nomenclature carries info: a name with 'Trust' suggests trust/wealth-management activity; 'Savings' suggests a thrift/savings institution. Categorize each bank by trailing-name signal: 'Trust' if name contains 'Trust', 'Savings' if name contains 'Savings', 'Other' otherwise. Show name_type, bank_count, total_assets_billions (rounded to 1 decimal — total_assets is in thousands, so divide by 1000000.0 to convert to billions). Order by bank_count descending.

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: Trust banks vs savings banks vs general

Hint

CASE WHEN name LIKE '%Trust%' THEN 'Trust' WHEN name LIKE '%Savings%' THEN 'Savings' ELSE 'Other' END. ⚠️ For the billions conversion use 1000000.0 (with the decimal), not 1000000 — SQLite does integer division when both operands are integers and you'll lose the fractional part (e.g. 20517.8 becomes 20517).

Concepts

SELECT WHERE LIKE CASE GROUP BY String Functions

Practise the topic: SQL practice questions · CASE WHEN practice · GROUP BY exercises · String 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

Movie Rating Tier BreakdownMedium · FreeGenre Financial ReportMedium · FreeDepartment Compensation ReportMedium · FreePivot: Order Status by CountryMedium · FreeGenre Box Office ReportMedium · FreeFare Imputation AnalysisMedium · 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