Practice Free
HardBusiness Analytics High Frequency

Collateral Risk Reserve Holdback for High-Chargeback Merchants

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

For each merchant in `merchant_monthly_stats`, determine their `reserve_rate`: - If `chargeback_ratio_pct >= 2.0`, rate is `0.15` (15% holdback) - If `chargeback_ratio_pct >= 1.0`, rate is `0.08` (8% holdback) - Otherwise, rate is `0.00` (No reserve) Calculate `reserve_holdback_usd` as `ROUND(gross_volume_usd * reserve_rate, 2)`. Return: 1. `merchant_id` 2. `gross_volume_usd` 3. `chargeback_ratio_pct` 4. `reserve_rate` 5. `reserve_holdback_usd` Order results by `reserve_holdback_usd` descending, then by `merchant_id` ascending.

Why Technical Interviewers Ask This

Payment gateways mitigate credit loss by automatically withholding rolling reserve holdbacks (between 5% and 15%) from merchant payouts when dispute ratios breach risk corridors.

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 
        merchant_id,
        gross_volume_usd,
        chargeback_ratio_pct,
        CASE 
          WHEN chargeback_ratio_pct >= 2.0 THEN 0.15
          WHEN chargeback_ratio_pct >= 1.0 THEN 0.08
          ELSE 0.00
        END AS reserve_rate,
        ROUND(
          gross_volume_usd * CASE 
            WHEN chargeback_ratio_pct >= 2.0 THEN 0.15
            WHEN chargeback_ratio_pct >= 1.0 THEN 0.08
            ELSE 0.00
          END,
          2
        ) AS reserve_holdback_usd
      FROM merchant_monthly_stats
      ORDER BY reserve_holdback_usd DESC, merchant_id ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Business Analytics. It meets the target criteria: Merchant collateral reserve holdback calculation based on chargeback ratios.

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