SQL Quest › SQL Interview Questions › Subqueries & CTEs
Above-Median NPL Banks
Identify banks with elevated non-performing loans (NPL ratio) — defined here as banks whose npl_ratio (period_end=20251231) is above the median NPL ratio across all top-200 banks. NPL ratio is a key credit-quality signal regulators watch. Use a CTE to compute the median (approximated via OFFSET on a sorted list — SQLite has no PERCENTILE_CONT). Show name, state, npl_ratio ordered by npl_ratio descending, top 15.
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: Banks with above-median credit stress
Hint
Concepts
SELECT CTE JOIN Subquery
Practise the topic: SQL practice questions · CTE practice · JOIN 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