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
SQL Joins, CTEs, and Pandas Strings
00:00
5 left

SQL Joins, CTEs, and Pandas Strings

HardSQL · PostgreSQL

Problem

How would you answer SQL questions on joins and CTEs, and Python questions using pandas for string manipulation?

For the SQL portion, write a query that analyzes merchants, customers, payments, and payment events for Q1 2025. The result should combine payment totals with repeat-customer and month-over-month metrics.

Output

  1. One row per merchant, including merchants without qualifying payments.
  2. Columns: merchant_name, total_success_amount, active_customers, repeat_customers, latest_success_date, and avg_monthly_change.
  3. Include only successful payments from Q1 2025 for payment metrics. Order by total_success_amount descending, then merchant_name ascending.

Schema

merchants
ColumnTypeDescription
merchant_idPKINTUnique merchant identifier
merchant_nameVARCHAR(100)Merchant display name
regionVARCHAR(50)Merchant operating region
customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer name
emailVARCHAR(150)Customer email address
payments
ColumnTypeDescription
payment_idPKINTUnique payment identifier
merchant_idINTMerchant receiving the payment
customer_idINTCustomer associated with the payment
amountNUMERIC(12,2)Payment amount
payment_statusVARCHAR(20)Payment lifecycle status
created_atDATEPayment creation date
payment_events
ColumnTypeDescription
event_idPKINTUnique payment event identifier
payment_idINTPayment associated with the event
event_typeVARCHAR(30)Payment event type
event_atTIMESTAMPEvent timestamp
Tablesmerchantscustomerspaymentspayment_events
Interviewer

Your question is SQL Joins, CTEs, and Pandas Strings. Start with the requirements and the four 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.