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 Conflicting User Profiles
00:00
5 left

Deduplicate Conflicting User Profiles

MediumSQL · PostgreSQL

Problem

Write a query or processing step to identify duplicate user profiles based on conflicting email and device identifiers.

Treat two profiles as duplicates when they share the same non-null email address or the same non-null device identifier. Return each unordered profile pair once.

Output

  1. One row per duplicate profile pair, ordered by profile_id_1, then profile_id_2.
  2. Columns: profile_id_1, profile_id_2, profile_name_1, profile_name_2, conflict_type, shared_email, and shared_device.
  3. conflict_type must identify an email conflict, device conflict, or both. Use NULL when a shared identifier does not apply.

Schema

user_profiles
ColumnTypeDescription
profile_idPKINTUnique user profile identifier
profile_nameVARCHAR(100)Display name associated with the profile
profile_identifiers
ColumnTypeDescription
profile_idPKINTUser profile identifier
emailVARCHAR(255)Email associated with the profile
device_idVARCHAR(100)Device identifier associated with the profile
Tablesuser_profilesprofile_identifiers
Interviewer

Your question is Deduplicate Conflicting User Profiles. 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.