Practice Free
HardBusiness Analytics High Frequency

Sanctions List Screening with Case-Insensitive Pattern Matching

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.

Solve in Workbench

Problem Statement

Join `outgoing_wires` with `sanctions_blacklist` matching on normalized uppercase name comparison (`UPPER(TRIM(w.beneficiary_name)) = UPPER(TRIM(s.sanctioned_entity_name))`). Return: 1. `w.wire_id` 2. `w.beneficiary_name` 3. `w.amount_usd` 4. `s.sanction_program` 5. `s.listing_date` Order results by `w.amount_usd` descending, then by `w.wire_id` ascending.

Why Technical Interviewers Ask This

Global banks must continuously screen wire transfer beneficiary names against OFAC (Office of Foreign Assets Control) sanctions lists to block terrorism and sanctioned state entities.

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 business analytics constructs.

Canonical Modern SQL Solution

PostgreSQL 16 / ANSI SQL
SELECT 
        w.wire_id,
        w.beneficiary_name,
        w.amount_usd,
        s.sanction_program,
        s.listing_date
      FROM outgoing_wires w
      JOIN sanctions_blacklist s ON UPPER(TRIM(w.beneficiary_name)) = UPPER(TRIM(s.sanctioned_entity_name))
      ORDER BY w.amount_usd DESC, w.wire_id ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Business Analytics. It meets the target criteria: Flagged wire transfers matching sanctioned names on official watchlists.

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 Business Analytics 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.

More FAANG SQL Interview Questions

View all questions