SQL QuestSQL Interview Questions › Aggregation & Grouping

Find Duplicate Emails

MediumFreeQuerying BasicsAggregation & Grouping

The data team found quality issues! Write a SQL query to find all duplicate email addresses in the customers table. Return the email and how many times it appears. Order by occurrence count descending. This is a classic interview question!

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

customers

customer_idnameemailsignup_datemembershiptotal_orders
1John Smithjohn.smith@email.com2023-01-15Gold15
2Emma Wilsonemma.wilson@email.com2023-03-20Silver8
3Michael Brownmichael.brown@email.com2023-02-10Gold12

Expected output: john.smith@email.com | 2, emma.wilson@email.com | 2, daniel.martinez@email.com | 2

Hint

GROUP BY email, then use HAVING COUNT(*) > 1 to find duplicates

Concepts

SELECT GROUP BY HAVING Aggregation GROUP BY + HAVING

Practise the topic: SQL practice questions · GROUP BY exercises

In these company practice sets

Plaid · Snowflake · Goldman Sachs

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Class Survival BreakdownMedium · FreeDepartment Roster with GROUP_CONCATMedium · FreeMovie Rating Tier BreakdownMedium · FreeFull Survival Dashboard by ClassMedium · FreeGenre Financial ReportMedium · FreeDepartment Compensation ReportMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test