Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Find Duplicate Transaction Records
00:00
5 left

Find Duplicate Transaction Records

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify duplicate records in a transaction table at i2c.

Treat records as duplicates when all business columns match, excluding transaction_id. Include duplicate records even when matching columns contain NULL values.

Output

  1. One row per duplicate transaction, including transaction_id, all business columns, and duplicate_count.
  2. Exclude transaction groups that occur only once.
  3. Order by transaction_id ascending.

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction record identifier
card_tokenVARCHAR(32)Tokenized card identifier
merchant_idINTMerchant identifier
amountNUMERIC(12,2)Transaction amount
currencyVARCHAR(3)ISO currency code
transaction_timeTIMESTAMPTime the transaction was recorded
transaction_typeVARCHAR(20)Transaction operation type
statusVARCHAR(20)Processing status
Tablestransactions
Interviewer

Your question is Find Duplicate Transaction Records. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.