PostgreSQL Database Quiz Questions

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

In PostgreSQL, the COALESCE function returns the first non-null value in the list of arguments.

Q2
True / False

The COALESCE function can only take two arguments in PostgreSQL.

Q3
True / False

In PostgreSQL, COALESCE(NULL, 'Hello') will return 'NULL'.

Q4
True / False

In PostgreSQL, COALESCE is a standard SQL function and is supported by PostgreSQL.

Q5
True / False

You can use the COALESCE function in PostgreSQL to handle NULL values in SELECT statements.

Q6
True / False

The COALESCE function in PostgreSQL can be used with different data types in the same call.

Q7
True / False

In PostgreSQL, using COALESCE in a WHERE clause can improve query performance by avoiding NULL comparisons.

Q8
True / False

In PostgreSQL, COALESCE(a, b) is equivalent to CASE WHEN a IS NOT NULL THEN a ELSE b END.

Q9
True / False

PostgreSQL’s COALESCE function can be used to provide a default value for a column in an INSERT statement.

Q10
True / False

: In PostgreSQL, the COALESCE function can be used in window functions to replace NULL values in the result set.

Q11
Single Choice

In PostgreSQL, what does the COALESCE function do?

Q12
Single Choice

Which of the following SQL statements correctly uses the COALESCE function in PostgreSQL?

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

In PostgreSQL, if all arguments passed to COALESCE are NULL, what will be the result?

Q14
Single Choice

Given the PostgreSQL table employees with columns first_name, middle_name, and last_name, which SQL query will return the first non-null value from these columns for each row?

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

What is the result of the following PostgreSQL query?

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

Consider the following PostgreSQL query:

SQL Code
SELECT COALESCE(salary, 50000) FROM employees WHERE id = 1;
If the salary for id = 1 is NULL, what will the query return?
Q17
Single Choice

In PostgreSQL, how does the COALESCE function handle type mismatches among its arguments?

SQL Code
SELECT COALESCE(100, 'default');
Q18
Single Choice

What will be the result of the following PostgreSQL query?

SQL Code
SELECT COALESCE(NULL, 5.7, 10.2)::INTEGER;
Q19
Single Choice

Given the PostgreSQL table orders with columns order_date, shipped_date, and delivery_date, what does the following query return?

SQL Code
Given the PostgreSQL table orders with columns order_date, shipped_date, and delivery_date, what does the following query return?
Q20
Single Choice

Consider a PostgreSQL query that uses COALESCE to handle NULLs in a complex report. Which of the following best describes an optimal scenario for using COALESCE in a PostgreSQL-based data reporting tool?

Q21
Multiple Choice

Which SQL statement correctly uses the COALESCE function to handle NULL values?

SQL Code
SELECT COALESCE(nickname, first_name) AS display_name
FROM employees;
Q22
Multiple Choice

How can the COALESCE function be used to handle multiple NULL columns in a query?

SQL Code
SELECT COALESCE(short_description, description, product_name) AS display_text
FROM products;
Q23
Multiple Choice

How does COALESCE function behave when all arguments are NULL?

SQL Code
SELECT COALESCE(NULL, NULL, NULL) AS result;
Q24
Multiple Choice

What happens when COALESCE is used with different data types?

SQL Code
SELECT COALESCE(NULL, 100, 'N/A') AS result;
Q25
Multiple Choice

Can COALESCE be used in the WHERE clause to filter results based on non-NULL values?

SQL Code
SELECT * FROM orders WHERE COALESCE(customer_id, order_status) IS NOT NULL;
Q26
Multiple Choice

How does the COALESCE function behave with aggregate functions in a query?

SQL Code
SELECT COALESCE(SUM(amount), 0) AS total_amount FROM payments;
Q27
Multiple Choice

What is the output of COALESCE when applied to columns with NULL and non-NULL values?

SQL Code
SELECT COALESCE(paid_amount, total_due) AS amount_to_pay FROM invoices;
Q28
Multiple Choice

How can COALESCE be used to provide default values in a SELECT statement?

SQL Code
SELECT COALESCE(email, 'Unknown') AS user_email FROM users;
Q29
Multiple Choice

How does COALESCE handle multiple arguments in a SELECT statement?

SQL Code
SELECT COALESCE(phone_number, mobile_number, 'No Contact Info') AS contact_info FROM customers;
Q30
Multiple Choice

What happens when COALESCE is combined with other functions in PostgreSQL?

SQL Code
SELECT COALESCE(MAX(discount), 0) AS max_discount FROM sales;