EasyFundamentals
Flagged Cross-Border Wire Transfers
Frequently Asked By:AmazonShopifyUber
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
Query the `wire_transfers` table to identify transfers where:
- `amount_usd` is between **10,000.00** and **50,000.00** (inclusive) using `BETWEEN`
- `risk_score` is greater than or equal to **75**
- `destination_country` is **not** `'USA'`
Return:
1. `transfer_id`
2. `destination_country`
3. `amount_usd`
4. `risk_score`
Order by `risk_score` descending, then by `amount_usd` descending.
Why Technical Interviewers Ask This
A global neo-bank AML (Anti-Money Laundering) compliance officer must inspect high-risk international wire transfers. Federal regulations mandate auditing transfers between $10,000 and $50,000 USD where the automated fraud risk score is 75 or higher.
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
transfer_id,
destination_country,
amount_usd,
risk_score
FROM wire_transfers
WHERE amount_usd BETWEEN 10000.00 AND 50000.00
AND risk_score >= 75
AND destination_country != 'USA'
ORDER BY risk_score DESC, amount_usd DESC;Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Fundamentals. It meets the target criteria: High-risk non-US wire transfers between $10k and $50k, sorted by highest risk score first.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 Amazon and Shopify 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.