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 for Duplicates and Trends
00:00
5 left

SQL for Duplicates and Trends

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify duplicate transactions or analyze merchant transaction volumes over time at Visa.

For this exercise, identify duplicate transaction groups where the merchant, card token, amount, transaction date, and transaction type are identical. Exclude records without a card token and exclude duplicate groups whose merchant is not present in the merchant reference table.

Output

  1. One row per duplicate transaction group.
  2. Columns: merchant_name, card_token, amount, transaction_date, transaction_type, duplicate_count, and first_transaction_id.
  3. Include only groups with at least two transactions, ordered by merchant_name, transaction_date, amount, and card_token ascending.

Schema

visa_transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
merchant_idINTMerchant receiving the transaction
card_tokenVARCHAR(64)Tokenized card identifier
amountDECIMAL(12,2)Transaction amount in the transaction currency
transaction_dateDATECalendar date of the transaction
transaction_typeVARCHAR(30)Transaction operation type
visa_merchants
ColumnTypeDescription
merchant_idPKINTUnique merchant identifier
merchant_nameVARCHAR(150)Merchant display name
merchant_countryVARCHAR(2)ISO-style merchant country code
Tablesvisa_transactionsvisa_merchants
Interviewer

Your question is SQL for Duplicates and 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.