Complete the code to return the first non-null value between 'email' and 'phone'.
SELECT COALESCE([1], phone) AS contact FROM users;The COALESCE function returns the first non-null value. Here, it checks 'email' first.
Complete the code to replace NULL 'salary' values with 0.
SELECT employee_id, COALESCE(salary, [1]) AS salary FROM employees;COALESCE replaces NULL with the value you provide. Here, 0 is used to indicate no salary.
Fix the error in the code to return the first non-null value among 'nickname', 'firstname', and 'lastname'.
SELECT COALESCE(nickname, [1], lastname) AS display_name FROM contacts;The COALESCE function checks values in order. 'firstname' should be the second argument to check after 'nickname'.
Fill both blanks to return the first non-null value among 'city', 'state', and 'country'.
SELECT COALESCE([1], [2], country) AS location FROM addresses;
The COALESCE function checks 'city' first, then 'state', then 'country'.
Fill all three blanks to return the first non-null value among 'home_phone', 'mobile_phone', and 'work_phone'.
SELECT COALESCE([1], [2], [3]) AS primary_phone FROM contacts;
The COALESCE function checks 'home_phone' first, then 'mobile_phone', then 'work_phone'.