Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Duplicate Emails

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

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

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results