Account Balance Over Threshold
Reported by candidates from IMC's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The whole IMC question from September 2020 hinges on one structure: a join between LOGIN and BALANCE on ACCOUNT. That's it. If you've got an OA invite for this one, it's a short SQL problem that rewards clean thinking over clever tricks. You return one column, USERNAME, for every account with AMOUNT strictly above 10000. Row order doesn't matter. The risk isn't difficulty, it's blanking on syntax or fumbling the boundary. StealthCoder is the safety net running invisibly during the live OA if your mind goes empty, but this one you can have down tonight.
The problem
You are given two tables, LOGIN and BALANCE. LOGIN ACCOUNT CHAR(16) USERNAME CHAR(20) FIRST_NAME CHAR(20) LAST_NAME CHAR(30) BALANCE ACCOUNT CHAR(16) AMOUNT INT LAST_UPDATED DATE Return exactly one column, USERNAME, containing every username whose matching BALANCE.AMOUNT is strictly greater than 10000. The output row order is not significant. Tables LOGIN: ACCOUNT (Text), USERNAME (Text), FIRST_NAME (Text), LAST_NAME (Text) BALANCE: ACCOUNT (Text), AMOUNT (Integer), LAST_UPDATED (Date) Constraints For this practice version, every input cell is non-null. LOGIN.ACCOUNT identifies at most one login row, and BALANCE.ACCOUNT identifies at most one current balance row. Text values respect the source-declared CHAR lengths. AMOUNT is a signed integer. LAST_UPDATED is represented as an ISO date in YYYY-MM-DD form and does not affect the result. Either table may be empty. A row without a matching account in the other table contributes no username.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is a plain inner join with a filter. Join LOGIN to BALANCE on ACCOUNT, then keep rows where AMOUNT > 10000, and select only USERNAME. Because each ACCOUNT appears at most once in each table, you won't get duplicate usernames from the join, so DISTINCT isn't needed (it's harmless though). The inner join also handles the unmatched case for free, since accounts missing from either table drop out. Pitfalls are small but real: using >= instead of >, selecting extra columns when the spec says exactly one, and using a LEFT JOIN that drags in unmatched rows. Ignore LAST_UPDATED completely, it's a distractor. Empty tables just return an empty result. If you freeze on the live OA, StealthCoder can supply the query as a hedge, but the logic is two lines.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Account Balance Over Threshold cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass IMC's OA.
IMC reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Account Balance Over Threshold FAQ
How hard is the IMC Account Balance Over Threshold question really?+
Easy. It's one join and one WHERE clause. The difficulty is purely in not overthinking it or missing the strict inequality. If you know basic INNER JOIN syntax, you can finish it in a couple of minutes.
What's the trick to this query?+
Join LOGIN and BALANCE on ACCOUNT, filter AMOUNT > 10000, and select only USERNAME. The trick is restraint. Don't add grouping, subqueries, or window functions. The one-to-one account relationship means no deduplication is required.
Should I use INNER JOIN or LEFT JOIN?+
INNER JOIN. You only want usernames whose account has a matching balance above the threshold. A LEFT JOIN keeps unmatched logins, and the WHERE filter would drop them anyway, so INNER is cleaner and matches the intent.
Do I need DISTINCT or ORDER BY?+
No to both. Each account maps to at most one login row and one balance row, so duplicates can't appear. The problem says output order isn't significant, so skip ORDER BY. Adding DISTINCT is safe but unnecessary.
How do I prepare for this in 48 hours?+
Write the join-plus-filter query from memory a few times, then try variants: different thresholds, a LEFT JOIN version, and finding accounts with no balance. Also recheck strict versus inclusive comparisons. That covers nearly everything this style of SQL OA tests.