Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Top Branch Failure Rate SQL
00:00
5 left

Top Branch Failure Rate SQL

MediumSQL · PostgreSQL

Problem

Mercantile Bank wants to identify branches with the highest transaction failure rates over the most recent 30-day reporting period. Write a SQL query to calculate each branch's total transactions and failure percentage for that period.

Output

  1. Return up to five rows, with one row per branch.
  2. Include branch_name, total_transactions, and failure_percentage.
  3. Include branches with no qualifying transactions, but do not allow them to outrank branches with transactions.
  4. Treat only transactions whose status is FAILED as failures. Transactions with other statuses, including NULL, count toward the total but not the failure count.
  5. Sort by failure percentage descending, then total transactions descending, then branch ID ascending. Use a fixed reporting date of 2026-09-26; the 30-day period includes that date and the preceding 29 days.

Schema

branches
ColumnTypeDescription
branch_idPKINTUnique Mercantile Bank branch identifier
branch_nameVARCHAR(100)Mercantile Bank branch name
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
branch_idINTBranch where the transaction was processed
transaction_dateDATEDate the transaction was processed
statusVARCHAR(20)Transaction outcome, such as SUCCESS or FAILED
Tablesbranchestransactions
Interviewer

Your question is Top Branch Failure Rate SQL. 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.