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
Merchant Volume Trends
00:00
5 left

Merchant Volume Trends

MediumSQL · PostgreSQL

Problem

Mastercard analytics teams monitor transaction activity by Merchant Category Code, or MCC. Treat transaction volume as the number of settled transactions. Write a PostgreSQL query that summarizes daily activity for each matched merchant category.

Requirements

  1. Join settled transactions to merchant_categories using mcc_code.
  2. Return the daily transaction count for each category and date.
  3. Calculate a cumulative running total within each category, ordered by transaction date.
  4. Calculate a three-row moving average of daily transaction volume, including the current day and up to the two preceding category rows. Round it to two decimal places.

Schema

payment_transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
mcc_codeINTMastercard Merchant Category Code
transaction_dateDATESettlement date
statusVARCHAR(20)Transaction processing status
merchant_categories
ColumnTypeDescription
mcc_codePKINTMastercard Merchant Category Code
category_nameVARCHAR(100)Human-readable merchant category
Tablespayment_transactionsmerchant_categories
Interviewer

Your question is Merchant Volume Trends. 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.