Skip to content
RED SAGSkills

Customer Email Domains

Count customers per email domain. The domain is everything after the @, lowercased. Every email contains exactly one @.

Return columns domain, customer_count. Order by customer_count descending, then domain ascending.

Schema

CREATE TABLE customers (
  customer_id INTEGER PRIMARY KEY,
  email TEXT NOT NULL
);

Sample data

customers

customer_idemail
1amir@gmail.com
2beth@outlook.com
3cyrus@Gmail.com
4dana@redsag.ae
5eli@gmail.com
6fatima@outlook.com
7gio@yahoo.com
Hint 1

INSTR(email, '@') gives the position of the @ sign.

Hint 2

SUBSTR(text, start) with no length returns the rest of the string.

Good practice for: Data Analyst, Digital Marketing Specialist, Data Engineer

SQL (SQLite)

Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.