SQL Quest › SQL Interview Questions › Joins
Trust Banks vs Others — NPL Profile Comparison
Pattern-based screening. Do banks with 'Trust' in their name (typical wealth-management institutions) carry different credit-quality patterns than other banks? This is the kind of segmentation question fraud analysts run to find anomalous sub-populations. Compare avg npl_ratio + bank count + total assets between Trust banks (name LIKE '%Trust%') and Other banks, using period_end=20251231. Output two rows: bank_type ('Trust' or 'Other'), bank_count, avg_npl_ratio (rounded to 3 decimals), total_assets_billions (rounded to 1 decimal — total_assets is in thousands, divide by 1000000.0 to get 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
| cert | name | city | state | zip | charter_class | established_date | total_assets | total_deposits | total_equity | office_count | bank_class |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 628 | JPMorgan Chase Bank, National Association | Columbus | OH | 43240 | 8 | 01/01/1824 | 3752662000 | 2697842000 | 335936000 | 5335 | N |
| 3510 | Bank of America, National Association | Charlotte | NC | 28202 | 13044 | 10/17/1904 | 2636823000 | 2101968000 | 246250000 | 3840 | N |
| 7213 | Citibank, National Association | Sioux Falls | SD | 57108 | 1461 | 06/16/1812 | 1836436000 | 1465300000 | 176530000 | 958 | N |
financials
| cert | name | period_end | total_assets | total_deposits | total_equity | net_income | net_loans | loan_loss_allowance | npl_ratio | tier1_capital_ratio | return_on_assets | return_on_equity |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 628 | JPMORGAN CHASE BANK NA | 20251231 | 3752662000 | 2697842000 | 335936000 | 49644000 | 1471951000 | 25539000 | 0.3618498015542034 | 15.29035880700036 | 1.3448553188805723 | 15.32 |
| 3510 | BANK OF AMERICA NA | 20251231 | 2636823000 | 2101968000 | 246250000 | 30380000 | 1166885000 | 13188000 | 0.38356764940232996 | 12.471807379783922 | 1.1544462063028051 | 12.24 |
| 7213 | CITIBANK NATIONAL ASSN | 20251231 | 1836436000 | 1465300000 | 176530000 | 15178000 | 700763000 | 17160000 | 0.30254253347244336 | 14.327392160721764 | 0.8458257679165101 | 8.67 |
Expected output: Two-row comparison: Trust vs Other
Hint
1000000.0 (with .0), not 1000000 — SQLite integer division will silently drop the fractional part.Concepts
SELECT JOIN GROUP BY CASE Aggregation GROUP BY + CASE
Practise the topic: SQL practice questions · JOIN practice · GROUP BY exercises · CASE WHEN practice
In these company practice sets
A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.
Related questions
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