EasyFundamentals
Banking Dispute Escalation Routing
Frequently Asked By:StripeCoinbaseBloomberg
Interactive In-Browser Workspace
Practice this problem on live schema tables in PostgreSQL 16 WASM with instant row verification and visual EXPLAIN plans.
Problem Statement
Assign each dispute in `dispute_tickets` a `priority_level` based on these rules:
- If `disputed_amount >= 1000.00` OR `reason_code = 'unauthorized_charge'` -> `'CRITICAL'`
- Else if `disputed_amount >= 200.00` -> `'HIGH'`
- Else -> `'STANDARD'`
Return:
1. `dispute_id`
2. `account_id`
3. `disputed_amount`
4. `reason_code`
5. `priority_level`
Order by `disputed_amount` descending, then by `dispute_id` ascending.
Why Technical Interviewers Ask This
A digital payments gateway handles transaction disputes. Compliance mandates assigning a routing priority: disputes over $1,000 or marked with 'unauthorized_charge' are 'CRITICAL'; disputes between $200 and $1,000 are 'HIGH'; all other disputes are 'STANDARD'.
Common Pitfalls & Interview Traps
Forgetting required sorting and deterministic tie-breaking.
Not accounting for NULL or zero-value denominators during calculations.
Using inefficient quadratic subqueries instead of single-pass fundamentals constructs.
Canonical Modern SQL Solution
PostgreSQL 16 / ANSI SQLSELECT
dispute_id,
account_id,
disputed_amount,
reason_code,
CASE
WHEN disputed_amount >= 1000.00 OR reason_code = 'unauthorized_charge' THEN 'CRITICAL'
WHEN disputed_amount >= 200.00 THEN 'HIGH'
ELSE 'STANDARD'
END AS priority_level
FROM dispute_tickets
ORDER BY disputed_amount DESC, dispute_id ASC;Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Fundamentals. It meets the target criteria: Dispute tickets classified by escalation priority and sorted by disputed amount.Edge Cases to Verbally Clarify with Your Interviewer
The dataset contains zero matching records (must return valid empty result without crashing).
Multiple records tie on sorting criteria (must evaluate tie-breaking order deterministically).
Foreign keys or secondary attributes have NULL values.
Frequently Asked Follow-Up Questions
What makes this question a favorite among Stripe and Coinbase interviewers?
Interviewers use this problem to test whether candidates write defensive, scalable Fundamentals queries that run efficiently on multi-million row production databases without excessive memory usage.
How does the query optimizer execute this query?
Using single-pass table scans with index lookups or sort buffers. Running EXPLAIN (ANALYZE, BUFFERS) in the DB Exercises workbench visualizes the execution nodes and buffer hit cache.