Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Branch KPIs
00:00
5 left

SQL for Branch KPIs

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze branch-level transaction volumes, failed transactions, and average turnaround time by month.

Use the provided branch and transaction data. Include only transactions associated with a known branch, and calculate turnaround time from initiation to completion.

Output

  1. One row per branch and calendar month
  2. Columns: branch_code, branch_name, month, total_transactions, failed_transactions, and avg_turnaround_minutes
  3. Include failed transactions in the total count, count failed transactions separately, and ignore incomplete turnaround times when calculating the average
  4. Order by branch_code, then month ascending

Schema

branches
ColumnTypeDescription
branch_codePKINTUnique branch identifier
branch_nameVARCHAR(100)Official branch name
cityVARCHAR(80)City where the branch operates
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
branch_idINTBranch that processed the transaction
statusVARCHAR(20)Transaction processing status
initiated_atTIMESTAMPTransaction initiation timestamp
completed_atTIMESTAMPTransaction completion timestamp
Tablesbranchestransactions
Interviewer

Your question is SQL for Branch KPIs. Start with the requirements and the two 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.