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
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 Transaction Payments
00:00
5 left

SQL for Transaction Payments

MediumSQL · PostgreSQL

Problem

Tell me about a time you solved a SQL problem on a transaction-level payments table and then designed the data model to support reporting or analytics.

For this exercise, use the provided payments and merchants tables to produce a reporting-ready monthly payment summary. Include only settled transactions and calculate refunds as negative amounts.

Output

  1. One row per merchant and calendar month with settled activity
  2. Columns: merchant_id, merchant_name, account_region, report_month, settled_transaction_count, and net_amount
  3. Exclude merchants without settled transactions and payments without a matching merchant
  4. Order by merchant name, month, and merchant ID

Schema

merchants
ColumnTypeDescription
merchant_idPKINTStable identifier for the merchant
merchant_nameVARCHAR(100)Display name of the merchant
account_regionVARCHAR(30)Reporting region assigned to the merchant
created_atTIMESTAMPTimestamp when the merchant record was created
payments
ColumnTypeDescription
payment_idPKINTUnique transaction identifier
merchant_idINTMerchant associated with the payment
transaction_tsTIMESTAMPTime when the payment transaction occurred
transaction_typeVARCHAR(20)Transaction direction, such as capture or refund
statusVARCHAR(20)Processing status of the transaction
amountNUMERIC(12,2)Transaction amount in the stated currency
currencyVARCHAR(3)ISO currency code
Tablespaymentsmerchants
Interviewer

Your question is SQL for Transaction Payments. 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.