Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rank Drivers of Failed Payments

Medium
SQL & Data ManipulationJoinsCase WhenAggregationsAsked 2 times

Problem

Intuit's payments team wants to understand which account and transaction attributes are most associated with failed payments in June 2024.

Write a SQL query to return the top driver values across four dimensions: payment_method, surface_name, country_code, and risk_tier.

Requirements

  1. Use only transactions from 2024-06-01 through 2024-06-30.
  2. Join transaction data to account and merchant metadata.
  3. For each dimension value, calculate:
    • total_transactions
    • failed_transactions where status = 'failed'
    • failure_rate = failed_transactions / total_transactions, rounded to 4 decimals
  4. Return only groups with at least 2 failed transactions.
  5. Rank rows within each dimension by failed_transactions descending, then total_transactions descending, then driver_value ascending.

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
account_idINTAccount associated with the transaction
transaction_tsTIMESTAMPTimestamp when the transaction was attempted
payment_methodVARCHAR(50)Payment method used for the transaction
statusVARCHAR(20)Final transaction status
failure_reasonVARCHAR(100)Failure reason when a transaction fails
amountNUMERIC(10,2)Transaction amount
accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
country_codeVARCHAR(2)Country code for the account
risk_tierVARCHAR(20)Risk segment assigned to the account
merchant_idINTMerchant linked to the account
merchants
ColumnTypeDescription
merchant_idPKINTUnique merchant identifier
surface_nameVARCHAR(50)Product surface where the merchant operates
merchant_nameVARCHAR(100)Merchant display name

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
SELECT ...
FROM ...
JOIN ... ON ...
GROUP BY ...
HAVING ...
ORDER BY ... DESC;
Sign up to unlock solutions
Adyen Operations Manager Interview QuestionsAdyen Interview Questions
Next questions
Airtel Payments BankSQL Transaction Failure DriversMediumAffirmTop Failed Payments in Rolling WindowHardPhonepeTop Failed Users YesterdayMedium
PostgreSQL