Problem · Easy · 15 min
The best way to reach a person
- Easy
- Missing values
- Conditional logic
A phone book keeps three ways to reach each person in the table people.
| Column | Meaning |
|---|---|
id |
The number of the person. It is unique. |
name |
The name of the person. |
mobile |
The mobile number. It can be NULL, or empty text. |
home |
The home number. It can be NULL, or empty text. |
email |
The email address. It can be NULL, or empty text. |
Write one query that returns one row for each person, with the columns name and contact.
contactis the first ofmobile,homeandemailthat exists. A value exists when it is notNULLand it is not empty text ('').- If none of the three values exists,
contactis the textnone. - Sort the rows by
id.
Tasks
2 to do
Task 1, not checked yet. Return the right rows for the example data.
Task 2, not checked yet. Return the right rows for other data that you cannot see.
Task 1 of 2
Return the right rows for the example data.