Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Client Transactions With Missing Values

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

Your question is SQL Client Transactions With Missing Values. 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

The JPMorganChase Data Analytics team needs a client-level summary of activity recorded across Chase client, account, and transaction tables. Write a PostgreSQL query for completed transactions during the first quarter of 2025.

Requirements

  1. Return every client, including clients with no qualifying account or transaction.
  2. Aggregate completed transaction count, total amount, and average amount per client. Treat NULL transaction amounts as zero for total and average calculations.
  3. Replace a missing client segment with Unclassified.
  4. Sort by total completed amount descending, then client_id ascending.

Schema

clients
ColumnTypeDescription
client_idPKINTUnique Chase client identifier
client_nameVARCHAR(100)Client's display name
client_segmentVARCHAR(40)Client coverage segment
accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
client_idINTOwning client identifier
account_typeVARCHAR(40)Account category
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
account_idINTRelated account identifier
transaction_dateDATETransaction posting date
statusVARCHAR(20)Processing status
amountNUMERIC(12,2)Transaction amount
Tablesclientsaccountstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results