Functions, Dates and Cleaning · Problem 16 of 118

Full Names

EasyFunctions, Dates and CleaningShop data

Return customer_id and a column full_name made of the first name, a single space and the last name, for customers 1 to 8 sorted by customer_id.

Hint 1

|| glues text together. Do not forget the space between the names.

Reference solution

SELECT customer_id,
       first_name || ' ' || last_name AS full_name
FROM customers
WHERE customer_id BETWEEN 1 AND 8
ORDER BY customer_id;

a || b joins two pieces of text. In SQLite (and standard SQL) a NULL on either side makes the whole result NULL; here both names are always present, so it is safe. Some databases use CONCAT(a, b) instead, and some treat NULLs differently, so check your database's documentation.