Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Top Clients by Volume per Region
00:00
5 left

Top Clients by Volume per Region

MediumSQL · PostgreSQL

Problem

Business Context

You’re a data engineer at a fintech payments processor that settles card and ACH payments for tens of thousands of SMB and mid-market clients across multiple geographic regions. The revenue team runs quarterly business reviews (QBRs) and wants to identify the most important clients in each region by transaction volume (count of transactions) in the most recently completed calendar quarter. This output feeds an executive dashboard and also triggers account-management workflows, so accuracy around quarter boundaries and tie-handling matters.

Task

Write a SQL query to return the top 3 clients by transaction volume for each region in the last completed quarter.

Requirements

  1. Consider only transactions with status = 'SETTLED'.
  2. Define last quarter as the most recently completed calendar quarter relative to CURRENT_DATE (e.g., if today is 2026-02-13, last quarter is 2025 Q4: 2025-10-01 through 2025-12-31).
  3. Compute transaction volume as COUNT(*) of settled transactions per (region, client_id) in that quarter.
  4. Return exactly 3 rows per region when possible. If a region has fewer than 3 clients with settled transactions in the quarter, return all of them.
  5. Break ties deterministically by ordering by txn_count DESC, then total_amount_usd DESC, then client_id ASC.
  6. Output columns: region, client_id, client_name, txn_count, total_amount_usd, rank_in_region.

Schema

regions
ColumnTypeDescription
region_idPKINTPrimary key
regionVARCHAR(50)Region name (e.g., 'NA', 'EMEA')
clients
ColumnTypeDescription
client_idPKINTPrimary key
client_nameVARCHAR(255)Legal/business name
region_idINTForeign key to regions.region_id
onboarded_atDATEDate client started processing
transactions
ColumnTypeDescription
transaction_idPKBIGINTPrimary key
client_idINTForeign key to clients.client_id
created_atTIMESTAMPTransaction creation timestamp
amount_usdDECIMAL(12,2)Amount in USD
statusVARCHAR(20)Transaction status (e.g., SETTLED, DECLINED)
Tablesregionsclientstransactions
Interviewer

Your question is Top Clients by Volume per Region. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.