Practice

Problem 2 of 8

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.

  • contact is the first of mobile, home and email that exists. A value exists when it is not NULL and it is not empty text ('').
  • If none of the three values exists, contact is the text none.
  • Sort the rows by id.

Tasks

2 to do

  1. Task 1, not checked yet. Return the right rows for the example data.

  2. 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.

All tasks

query.sql

Ctrl+Enter runs your code. Ctrl+Shift+Enter runs all the tests. Press Esc, then Tab, to leave the editor.

Output

Press Run to see your result

Your output shows here. Press Run to try your code.