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
Deduplicate Transactions Across Channels
00:00
5 left

Deduplicate Transactions Across Channels

MediumSQL · PostgreSQL

Problem

Wayfair receives transaction records from multiple fulfillment channels, including Wayfair.com, the Wayfair app, and CastleGate. The same transaction may appear more than once when records are passed through multiple channels.

Write a PostgreSQL query that returns one canonical record for each non-null transaction reference, keeping the earliest transaction by timestamp. Include the number of records found for each transaction reference so duplicate groups can be identified.

Requirements

  1. Join transactions to their fulfillment channel names.
  2. Exclude records with a null transaction reference or no matching fulfillment channel.
  3. Use a window function to rank records by transaction_timestamp, using transaction_id as a deterministic tie-breaker.
  4. Return only the earliest record for each transaction reference, ordered chronologically.

Schema

payment_transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction record identifier
transaction_referenceVARCHAR(30)Business reference shared by duplicate records
order_idINTWayfair order identifier
amountDECIMAL(10,2)Transaction amount
transaction_timestampTIMESTAMPTime the channel record was received
channel_idINTReferences fulfillment_channels.channel_id
fulfillment_channels
ColumnTypeDescription
channel_idPKINTFulfillment channel identifier
channel_nameVARCHAR(50)Name of the fulfillment channel
Tablespayment_transactionsfulfillment_channels
Interviewer

Your question is Deduplicate Transactions Across Channels. 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.