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
Branch Transaction Trend SQL
00:00
5 left

Branch Transaction Trend SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze branch transaction volumes by region and month, joining branch, transaction, and customer tables to identify trends and outliers.

Use completed transactions from active branches and active customers. Treat a month as an outlier when its regional total amount exceeds twice that region's average monthly total amount.

Output

  1. One row per region and month, with region, month, transaction_count, total_amount, average_amount, prior_month_count, percent_change, volume_rank, and volume_flag.
  2. Include all qualifying region-month rows, ordered by region and month ascending. Rank higher transaction counts first, breaking ties with higher total amounts.

Schema

branches
ColumnTypeDescription
branch_idPKINTUnique branch identifier
branch_nameVARCHAR(100)Branch name
regionVARCHAR(50)Geographic operating region
branch_statusVARCHAR(20)Operational status of the branch
transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
branch_idINTBranch processing the transaction
customer_idINTCustomer associated with the transaction
transaction_dateDATETransaction date
amountNUMERIC(12,2)Transaction amount
transaction_statusVARCHAR(20)Processing status
customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer name
customer_statusVARCHAR(20)Customer account status
Tablesbranchestransactionscustomers
Interviewer

Your question is Branch Transaction Trend SQL. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.