Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top 10 Customers by Volume

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

Your question is Top 10 Customers by Volume. Start with the requirements and the two 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

Chase analytics needs a customer-level view of transaction volume for reporting in the Chase mobile app. Write a PostgreSQL query that identifies the 10 customers with the highest total value of completed transactions.

Requirements

  1. Join customers to transactions using customer_id.
  2. Include only transactions whose status is COMPLETED.
  3. Calculate total transaction volume with SUM(transaction_amount) for each customer.
  4. Return the top 10 customers, ordered by total volume descending and customer ID ascending to make ties deterministic.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique Chase customer identifier
customer_nameVARCHAR(100)Customer display name
customer_segmentVARCHAR(30)Optional customer segment
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
customer_idINTCustomer associated with the transaction
transaction_amountNUMERIC(12,2)Monetary value of the transaction
transaction_dateDATEDate the transaction occurred
statusVARCHAR(20)Transaction processing status
Tablescustomerstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results