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
Finding Duplicate SQL Records
00:00
5 left

Finding Duplicate SQL Records

EasySQL · PostgreSQL

Problem

EAB Navigate stores advising interactions submitted by advisors. Data quality analysts need to identify repeated interaction records before these records are used in advising activity reports.

Write a PostgreSQL query that finds duplicate rows in advising_interactions. Two interactions are duplicates when they have the same student_id, advisor_id, interaction_date, channel, and topic. The interaction_id is a unique row identifier and must not be part of the duplicate definition.

Requirements

  1. Use a CTE to identify duplicate combinations with COUNT(*) > 1.
  2. Return every source row belonging to a duplicate group, including its interaction_id and duplicate count.
  3. Join to students to display the student name. Preserve duplicate interactions even when no student record exists.
  4. Treat duplicate rows with a NULL topic as belonging to the same duplicate group, and order results by student ID, interaction date, and interaction ID.

Schema

advising_interactions
ColumnTypeDescription
interaction_idPKINTUnique interaction row identifier
student_idINTEAB student identifier
advisor_idINTAdvisor identifier
interaction_dateDATEDate of the advising interaction
channelVARCHAR(30)Interaction channel
topicVARCHAR(100)Advising topic
students
ColumnTypeDescription
student_idPKINTStudent identifier
first_nameVARCHAR(50)Student first name
last_nameVARCHAR(50)Student last name
Tablesadvising_interactionsstudents
Interviewer

Your question is Finding Duplicate SQL Records. 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.