Duplicate Signup Emails
Some users signed up more than once with the same email, sometimes typed in different letter case (Ana@Mail.com and ana@mail.com are the same address).
Find every email used by more than one account, comparing emails case-insensitively. Report the email in lowercase.
Return columns email, account_count. Order by account_count descending, then email ascending.
Schema
CREATE TABLE users ( user_id INTEGER PRIMARY KEY, email TEXT NOT NULL, created_at TEXT NOT NULL );
Sample data
users
| user_id | created_at | |
|---|---|---|
| 1 | ana@mail.com | 2026-01-01 |
| 2 | bilal@corp.io | 2026-01-02 |
| 3 | Ana@Mail.com | 2026-01-05 |
| 4 | chloe@web.net | 2026-01-06 |
| 5 | BILAL@corp.io | 2026-01-07 |
| 6 | bilal@corp.io | 2026-01-09 |
| 7 | dev@site.org | 2026-01-10 |
Hint 1
Group by LOWER(email) so differently-cased copies fall into the same group.
Hint 2
HAVING filters groups after aggregation; WHERE cannot see COUNT(*).
Good practice for: Data Analyst, Data Engineer, Backend Developer, Database Administrator
SQL (SQLite)
Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.