The Users That Are Eligible for Discount
A easy-tier problem at 51% community acceptance, tagged with Database. Reported in interviews at Analytics quotient and 0 others.
This is a database problem that appears straightforward but trips up candidates who don't read the discount criteria carefully. You're filtering a users table against purchase or transaction thresholds, and the gotcha is usually in the join logic or the aggregate condition. Analytics quotient asks this. If you hit it cold in a live assessment and your first query returns wrong counts, StealthCoder will surface the correct GROUP BY and HAVING setup in seconds, invisible to the proctor. The acceptance rate of just over 50% tells you half the people submitting get it wrong on their first attempt.
Companies that ask "The Users That Are Eligible for Discount"
The Users That Are Eligible for Discount is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe core pattern is a filtered aggregate: sum or count transactions per user, then filter for users meeting a spending threshold. The failure mode is forgetting to aggregate before filtering (using WHERE instead of HAVING), or joining incorrectly so you count duplicate rows. Some candidates also miss that you need to ensure a user is in the result set only if they meet the condition, not just have one qualifying transaction. The SQL is simple but the mental model matters. When you're live and unsure which join type or whether to use a subquery, StealthCoder eliminates the guessing. You'll get a working solution that handles edge cases like users with no transactions or exactly the threshold amount.
Pattern tags
You know the problem.
Make sure you actually pass it.
The Users That Are Eligible for Discount recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
The Users That Are Eligible for Discount interview FAQ
Is this actually easy or is the difficulty label wrong?+
It's genuinely easy in concept but the 50% acceptance rate means many miss the aggregate logic. The trick isn't algorithmic complexity, it's not filtering before grouping. If you know GROUP BY and HAVING, you're fine.
Do I need a join or can I do it with a subquery?+
Both work. A subquery with SUM in the WHERE clause is cleaner for this problem. Alternatively, join users to transactions, aggregate in a subquery, then filter. The platform doesn't care as long as your row counts match.
What's the trick if the discount threshold is a column, not a fixed number?+
Then you're comparing each user's total to their own discount_threshold value, not a constant. Use a HAVING clause that compares the aggregate to the column value from the joined users row. This is why the join structure matters.
Will this question come up at other companies or just Analytics quotient?+
It's in the wild at Analytics quotient. Filtering aggregate results is a common pattern across all companies, so the underlying skill is universal even if this exact wording isn't.
How long should this take if I know SQL?+
5 to 10 minutes to write and test. If you're spending longer, you're overthinking the join or filtering logic. Write the aggregate query first, verify row counts, then add the filter.
Want the actual problem statement? View "The Users That Are Eligible for Discount" on LeetCode →