Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Duplicate Values After Transformation

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Duplicate Values After Transformation. Start with the requirements and the one table on the right.

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.

Problem

Apex Systems QA engineers are validating imported contact records. Some email addresses differ only by capitalization or accidental surrounding spaces, which can create duplicate accounts in an internal QA data set.

Write a PostgreSQL query to identify duplicate email values after applying the transformation LOWER(TRIM(external_email)).

Requirements

  1. Normalize each email by trimming surrounding whitespace and converting it to lowercase.
  2. Return only non-empty normalized values that occur more than once.
  3. Return the normalized email and its duplicate count, ordered alphabetically by the normalized email.

Schema

contact_imports
ColumnTypeDescription
import_idPKINTUnique imported record identifier
external_emailVARCHAR(255)Email value received from an external source
Tablescontact_imports
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results