Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.