Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top 10% Customers by Volume

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top 10% Customers by Volume. Start with the requirements and the three tables on the right.

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.

Problem

Business Context

Bank of America Merrill Lynch wants to identify its highest-volume customers for the latest completed calendar quarter. Transaction volume is defined as the sum of the absolute monetary value of valid posted transactions on open accounts.

Task

Write a PostgreSQL query that returns the top 10% of eligible customers by transaction volume for the last completed calendar quarter. The sample data represents an execution date of 2026-08-29, so the reporting period is 2026-04-01 through 2026-06-30.

Requirements

  1. Join customers, accounts, and transactions.
  2. Include only open accounts, posted transactions, non-null amounts, and transactions within the last completed calendar quarter.
  3. Aggregate absolute transaction amounts per customer.
  4. Rank customers by volume and return the top 10%, rounding the number of returned customers up when necessary.
  5. Return customer ID, customer name, and total transaction volume in descending order.

Schema

customers
ColumnTypeDescription
customer_idPKINTEGERUnique customer identifier
customer_nameVARCHAR(100)Customer full name
customer_segmentVARCHAR(40)Customer coverage segment
accounts
ColumnTypeDescription
account_idPKINTEGERUnique account identifier
customer_idINTEGEROwner of the account
account_statusVARCHAR(20)Account lifecycle status
opened_dateDATEDate the account was opened
transactions
ColumnTypeDescription
transaction_idPKINTEGERUnique transaction identifier
account_idINTEGERAccount associated with the transaction
transaction_dateDATETransaction posting date
amountNUMERIC(14,2)Signed monetary transaction amount
transaction_statusVARCHAR(20)Transaction processing status
Tablescustomersaccountstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results