SQL QuestSQL Interview Questions › Joins

Transactions at High-Risk Merchants

EasyFreeQuerying BasicsJoins

Risk tier is a merchant attribute. The transaction row has a merchant_id and nothing else about the merchant, so WHERE risk_tier = 'high' cannot run until you have joined merchants in. This is the single most common first mistake on a ledger screen: filtering on a column that is not in the FROM table yet.

Return the 20 largest transactions at merchants whose risk_tier is 'high': txn_id, merchant (the merchant's name), category, amount and txn_at. Order by amount descending, then txn_id ascending.

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

transactions

txn_idaccount_idamounttxn_atmerchant_idlatlngstatus
1149151.842026-03-04T12:39:39.078Z2440.342-74.4092completed
22110.722026-03-04T13:04:50.641Z752.936613.3229completed
335158.782026-03-04T13:27:15.528Z2552.739713.3134completed

merchants

merchant_idnamecategorycountryrisk_tier
1BigBox MartGroceryTRhigh
2Quick StopElectronicsJPhigh
3Aurora CafeTravelTRhigh

Expected output: 2129 BigBox Mart Grocery 8754.25 2026-05-02T12:00:00.000Z; ...

Hint

FROM transactions t JOIN merchants m ON m.merchant_id = t.merchant_id WHERE m.risk_tier = 'high'. Alias the merchant name as merchant — name on its own is ambiguous once two tables are in play. Three of the 25 merchants are high risk.

Concepts

SELECT JOIN WHERE ORDER BY LIMIT

Practise the topic: SQL practice questions · JOIN practice

In these company practice sets

Capital One · Stripe

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

Related questions

Your First JOINEasy · FreeJOIN with a FilterEasy · FreeLEFT JOIN: Watch the NULLs AppearEasy · FreeCounting Across a JOINEasy · FreeTransaction Share by Merchant CategoryEasy · FreeSignup-Month Cohort SpendEasy · 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