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
Find Duplicates Without DISTINCT
00:00
5 left

Find Duplicates Without DISTINCT

MediumSQL · PostgreSQL

Problem

Zebra Technologies receives device inventory data from systems supporting products such as Zebra TC53, TC58, and DS3678 devices. Duplicate imports can distort asset counts and downstream analytics.

Write a PostgreSQL query to find duplicate logical rows in device_inventory_imports without using DISTINCT. Treat rows as duplicates when all business columns match, excluding the surrogate import_id and ingestion timestamp.

Requirements

  1. Group by device_serial, device_model, firmware_version, warehouse_code, and lifecycle_status.
  2. Return only groups containing at least two records.
  3. Return the duplicate count and an ordered array of the corresponding import_id values.
  4. Treat NULL business values as equal for duplicate detection and order the output by duplicate count descending, then serial number.

Schema

device_inventory_imports
ColumnTypeDescription
import_idPKINTEGERUnique import record identifier
device_serialVARCHAR(30)Zebra device serial number
device_modelVARCHAR(40)Device model reported by the source system
firmware_versionVARCHAR(20)Reported firmware version
warehouse_codeVARCHAR(10)Warehouse holding the device
lifecycle_statusVARCHAR(20)Current lifecycle status
imported_atTIMESTAMPTZTimestamp when the source row was ingested
Tablesdevice_inventory_imports
Interviewer

Your question is Find Duplicates Without DISTINCT. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.