Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Duplicate Emails
00:00
5 left

SQL Duplicate Emails

EasySQL · PostgreSQL

Problem

Amazon account data may contain duplicate email addresses because of inconsistent capitalization or accidental leading and trailing spaces. Write a PostgreSQL query to identify emails associated with more than one user.

Requirements

  1. Normalize emails by removing leading and trailing whitespace and converting them to lowercase.
  2. Exclude NULL and empty email values.
  3. Return each normalized duplicate email and the number of users sharing it.
  4. Sort the results alphabetically by normalized email.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique Amazon user identifier
emailVARCHAR(320)User email address
created_atTIMESTAMPAccount creation timestamp
Tablesusers
Interviewer

Your question is SQL Duplicate Emails. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.