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_id | |
|---|---|
| 1 | amir@gmail.com |
| 2 | beth@outlook.com |
| 3 | cyrus@Gmail.com |
| 4 | dana@redsag.ae |
| 5 | eli@gmail.com |
| 6 | fatima@outlook.com |
| 7 | gio@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.