MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:COALESCE
Current Quiz Count:30
Progress
0%
Q1
True / False

The MySQL COALESCE function returns the first non-NULL value in the list of expressions.

Q2
True / False

In MySQL, COALESCE(NULL, 'default') will return NULL.

Q3
True / False

The MySQL COALESCE function can only take two arguments.

Q4
True / False

The MySQL COALESCE function can be used to handle NULL values in a SELECT statement.

Q5
True / False

In MySQL, COALESCE and IFNULL are completely interchangeable.

Q6
True / False

Using the COALESCE function in MySQL can improve query performance compared to using multiple IF statements.

Q7
True / False

In MySQL, COALESCE can be used within an UPDATE statement to set a column value based on multiple conditions.

Q8
True / False

The MySQL COALESCE function evaluates all its arguments, even if the first one is non-NULL.

Q9
True / False

In MySQL, COALESCE(NULL, NULL, NULL) will return an error.

Q10
True / False

In a MySQL certification exam, you might encounter a question asking whether the COALESCE function can handle expressions of different data types.

Q11
Single Choice

Which of the following best describes the COALESCE function in MySQL?

Q12
Single Choice

What does the following SQL query return?

SQL Code
SELECT COALESCE(NULL, 'MySQL', 'SQL');
Q13
Single Choice

In which of the following scenarios would the COALESCE function return NULL?

Q14
Single Choice

What will be the result of the following query using COALESCE?

SQL Code
SELECT COALESCE(NULL, NULL, 10, 20);
Q15
Single Choice

Which SQL statement using COALESCE will return 'UNKNOWN' if the status column contains NULL?

SQL Code
SELECT COALESCE(_____, 'UNKNOWN') FROM orders;
Q16
Single Choice

What will this query return if customer_name is NULL?

SQL Code
SELECT COALESCE(customer_name, 'No Name') AS customer FROM customers;
Q17
Single Choice

Given the following table employees with columns first_name, middle_name, and last_name, what will the following query return?

SQL Code
SELECT COALESCE(middle_name, first_name, last_name) FROM employees;
Q18
Single Choice

What is the difference between using COALESCE and IFNULL in MySQL?

Q19
Single Choice

What will be the result?

SQL Code
SELECT COALESCE(NULL, COALESCE(NULL, COALESCE(NULL, 'Nested')));
Q20
Single Choice

What does this query accomplish?

SQL Code
SELECT
 COALESCE(o.order_date, 'No Date') AS order_date,
 COALESCE(c.customer_name, 'No Name') AS customer_name
FROM orders o
LEFT JOIN customers c ON o.customer_id = c.customer_id;
Q21
Multiple Choice

Which SQL query uses COALESCE to replace NULL values in the 'phone' column with the value 'N/A'?

SQL Code
SELECT employee_id, COALESCE(phone, 'N/A') AS phone_number
FROM employees;
Q22
Multiple Choice

Identify the SQL query that uses COALESCE to handle NULL values in multiple columns for an employee's contact information.

SQL Code
SELECT employee_id, COALESCE(phone, email, 'No Contact') AS contact_info
FROM employees;
Q23
Multiple Choice

Which SQL query uses COALESCE to display the first available price for products across different price columns?

SQL Code
SELECT product_name, COALESCE(price_2022, price_2021, price_2020) AS current_price
FROM products;
Q24
Multiple Choice

Determine the SQL query that uses COALESCE to replace NULL values in an 'address' column with values from other address-related columns.

SQL Code
SELECT customer_id, COALESCE(address, alternate_address, 'Address Not Available') AS full_address
FROM customers;
Q25
Multiple Choice

Which SQL query uses COALESCE to fill missing 'department' values with 'Unknown' and then with 'General' if both are NULL?

SQL Code
SELECT employee_id, COALESCE(department, 'Unknown', 'General') AS department_name
FROM employees;
Q26
Multiple Choice

Which SQL query uses COALESCE to prioritize and display a customer's preferred contact method?

SQL Code
SELECT customer_id, COALESCE(phone, email, 'No Contact Available') AS preferred_contact
FROM customers;
Q27
Multiple Choice

Identify the SQL query that uses COALESCE to provide a fallback value for missing 'date_of_birth' data.

SQL Code
SELECT employee_id, COALESCE(date_of_birth, '1900-01-01') AS birth_date
FROM employees;
Q28
Multiple Choice

Which SQL query uses COALESCE to combine and display the most recent non-NULL value from multiple review columns?

SQL Code
SELECT product_name, COALESCE(review_2023, review_2022, review_2021, 'No Review') AS latest_review
FROM products;
Q29
Multiple Choice

Determine the SQL query that uses COALESCE to select the first available non-NULL value for a customer's loyalty tier.

SQL Code
SELECT customer_id, COALESCE(loyalty_tier_2023, loyalty_tier_2022, 'Standard') AS current_tier
FROM customers;
Q30
Multiple Choice

Which SQL query uses COALESCE to handle missing 'discount' values by replacing them with a default of 0?

SQL Code
SELECT order_id, COALESCE(discount, 0) AS applied_discount
FROM orders;