Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Joins Across Multiple Tables

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

Your question is SQL: Joins Across Multiple Tables. 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

Yes Bank's Business Analytics team needs a January 2025 view of customer account activity from its core banking transaction data.

Task

Write a PostgreSQL query using joins to return one row per Yes Bank customer and active account, including customers who have no active account or no qualifying transaction.

Requirements

  1. Join customers to active accounts and January 2025 successful transactions.
  2. Calculate successful transaction count and total credited amount per customer-account combination.
  3. Use COALESCE so accounts without qualifying transactions show zero total credit.
  4. Classify accounts with at least 100000 in successful credits as Priority, and all others as Standard.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique Yes Bank customer identifier
customer_nameVARCHAR(100)Customer's full name
segmentVARCHAR(30)Customer segment
accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
customer_idINTCustomer who owns the account
account_typeVARCHAR(30)Account product type
statusVARCHAR(20)Current account status
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
account_idINTAccount associated with the transaction
transaction_dateDATEDate on which the transaction was recorded
statusVARCHAR(20)Transaction processing status
amountDECIMAL(12,2)Transaction credit amount
Tablescustomersaccountstransactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results