Contacts With Email
EasySQLDatabaseSorting
Description
Write a SQL query to return the id and name of contacts whose email is not null, ordered by id ascending. **Output columns (in order):** id, name
Table:
contacts| Column | Type |
|---|---|
| id | INT |
| name | TEXT |
| TEXT |
Examples
Input:
CREATE TABLE contacts (id INT, name TEXT, email TEXT); INSERT INTO contacts VALUES (1,'A','a@x.com'),(2,'B',NULL),(3,'C','c@x.com');Output:
1|A
3|CExplanation:
Rows missing an email are excluded, leaving the contacts that have one, ordered by id.
Input:
CREATE TABLE contacts (id INT, name TEXT, email TEXT); INSERT INTO contacts VALUES (1,'A','x'),(2,'B','y');Output:
1|A
2|BExplanation:
Rows missing an email are excluded, leaving the contacts that have one, ordered by id.
Input:
CREATE TABLE contacts (id INT, name TEXT, email TEXT); INSERT INTO contacts VALUES (2,'P',NULL),(1,'Q','q@x');Output:
1|QExplanation:
Rows missing an email are excluded, leaving the contacts that have one, ordered by id.
Constraints
- •
Use standard SQL (SQLite).