Practice Free
MediumJoins

Unverified FinTech Accounts Missing Government ID

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 `app_users` to `kyc_documents` using a `LEFT JOIN` on `user_id` where `doc_status = 'approved'`. Find users who lack approved KYC verification where `u.registered_days_ago >= 14`. Return: 1. `u.user_id` 2. `u.user_email` 3. `u.account_tier` 4. `u.registered_days_ago` Order results by `u.registered_days_ago` descending, then by `u.user_id` ascending.

Why Technical Interviewers Ask This

Risk and fraud compliance teams need to isolate customer accounts registered over 14 days ago that still have zero approved government identification documents uploaded.

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 joins constructs.

Canonical Modern SQL Solution

PostgreSQL 16 / ANSI SQL
SELECT 
        u.user_id,
        u.user_email,
        u.account_tier,
        u.registered_days_ago
      FROM app_users u
      LEFT JOIN kyc_documents k ON u.user_id = k.user_id AND k.doc_status = 'approved'
      WHERE u.registered_days_ago >= 14
        AND k.doc_id IS NULL
      ORDER BY u.registered_days_ago DESC, u.user_id ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Joins. It meets the target criteria: Unverified user accounts registered >= 14 days without approved KYC documents.

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 Joins 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