Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top 5% Clients by Volume

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

Your question is Top 5% Clients 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

Write a query to identify the top 5% of clients by transaction volume over the last quarter.

Treat transaction volume as the number of transactions. Use the previous completed calendar quarter relative to the query execution date. Include only clients with at least one transaction during that quarter.

Output

  1. One row per selected client with client_id, client_name, and transaction_volume.
  2. Include the highest-volume 5% of clients, rounding the selection count up to at least one client.
  3. Order by transaction_volume descending, then client_id ascending to break ties.

Schema

clients
ColumnTypeDescription
client_idPKINTUnique client identifier
client_nameVARCHAR(100)Client display name
statusVARCHAR(20)Current client status
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
client_idINTClient associated with the transaction
transaction_dateDATEDate on which the transaction occurred
amountNUMERIC(12,2)Illustrative transaction amount
Tablesclientstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results