Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Customer Transactions SQL Query
00:00
5 left

Customer Transactions SQL Query

MediumSQL · PostgreSQL

Problem

Continental Finance wants to identify customers showing concentrated monthly transaction activity. Write a PostgreSQL query that reports customers with more than three completed transactions in a calendar month, using only transactions linked to active accounts.

Requirements

  1. Join customers, accounts, and transactions.
  2. Include only transactions from active accounts with completed status.
  3. Group transactions by customer and calendar month using PostgreSQL date functions.
  4. Return the customer, month, transaction count, and total amount. Treat a NULL amount as zero.
  5. Keep only groups with more than three transactions and order by total amount descending.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer full name
accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
customer_idINTCustomer who owns the account
account_statusVARCHAR(20)Current account status
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
account_idINTAccount associated with the transaction
transaction_dateDATEDate the transaction occurred
statusVARCHAR(20)Transaction processing status
amountNUMERIC(12,2)Transaction amount, which may be NULL
Tablescustomersaccountstransactions
Interviewer

Your question is Customer Transactions SQL Query. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.