PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:EXISTS, ANY and ALL Clause
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, the EXISTS operator is used to check if a subquery returns any rows.

Q2
True / False

In PostgreSQL, the ANY operator is used to compare a value against any value in a list or subquery.

Q3
True / False

In PostgreSQL, the ALL operator is used to compare a value against all values in a list or subquery.

Q4
True / False

In PostgreSQL, EXISTS can be used in the WHERE clause to filter rows based on the result of a subquery.

Q5
True / False

In PostgreSQL, the query SELECT * FROM table WHERE column = ANY (subquery) checks if column is equal to any value returned by the subquery.

Q6
True / False

In PostgreSQL, the query SELECT * FROM table WHERE column <> ALL (subquery) checks if column is different from all values returned by the subquery.

Q7
True / False

In PostgreSQL, using EXISTS in a correlated subquery can provide better performance than using IN in some cases.

Q8
True / False

In PostgreSQL, the query SELECT * FROM table WHERE 100 > ALL (SELECT column FROM other_table) will return all rows from table if 100 is greater than the maximum value returned by the subquery.

Q9
True / False

In PostgreSQL, the ANY operator can be used with different comparison operators (e.g., =, <, >) to compare values against the result of a subquery.

Q10
True / False

In PostgreSQL, using SELECT * FROM table WHERE NOT EXISTS (subquery) will return rows from table where the subquery does not return any rows.

Q11
Single Choice

Which clause would you use in PostgreSQL to check if a subquery returns any rows?

Q12
Single Choice

What does the following SQL query do?

SQL Code
SELECT *
FROM employees
WHERE EXISTS (
 SELECT 1
 FROM departments
 WHERE departments.manager_id = employees.id
);
Q13
Single Choice

Which of the following keywords would you use in PostgreSQL to compare a value to any value in a list or subquery?

Q14
Single Choice

What will the following PostgreSQL query return? sql

SQL Code
SELECT name
FROM products
WHERE price > ALL (
 SELECT price
 FROM competitors
 WHERE competitors.product_id = products.id
);
Q15
Single Choice

Which of the following queries correctly uses the ANY keyword in PostgreSQL?

SQL Code
SELECT name
FROM orders
WHERE quantity > ANY (
 SELECT quantity
 FROM order_items
 WHERE order_items.order_id = orders.id
);
Q16
Single Choice

What will the following PostgreSQL query do?

SQL Code
SELECT *
FROM customers
WHERE EXISTS (
 SELECT 1
 FROM orders
 WHERE orders.customer_id = customers.id
 AND orders.total > 500
);
Q17
Single Choice

Which query would return rows where a column value is greater than all other values returned by a subquery in PostgreSQL?

SQL Code
SELECT *
FROM sales
WHERE amount > ALL (
 SELECT amount
 FROM sales_region
 WHERE region = 'North'
);
Q18
Single Choice

What does the following PostgreSQL query achieve?

SQL Code
SELECT id
FROM students
WHERE id NOT IN (
 SELECT student_id
 FROM enrollments
 WHERE course_id = 101
);
Q19
Single Choice

In PostgreSQL, which clause would you use to ensure that a condition is true for all rows returned by a subquery?

Q20
Single Choice

Consider the following PostgreSQL query:

SQL Code
SELECT employee_id
FROM employees
WHERE salary > ALL (
 SELECT salary
 FROM employees
 WHERE department_id = 10
)
AND EXISTS (
 SELECT 1
 FROM departments
 WHERE department_id = employees.department_id
 AND location_id = 20
);
What does this query return?
Q21
Multiple Choice

Identify the SQL scripts that correctly use the EXISTS clause to filter rows in PostgreSQL.

Q22
Multiple Choice

Select the SQL scripts that correctly use the ANY clause with comparison operators in PostgreSQL.

Q23
Multiple Choice

Determine the SQL scripts that correctly use the ALL clause with comparison operators in PostgreSQL.

Q24
Multiple Choice

Identify the SQL scripts that correctly use the EXISTS clause with a correlated subquery in PostgreSQL.

Q25
Multiple Choice

Select the SQL scripts that correctly use the ANY clause to compare a value against multiple values returned by a subquery in PostgreSQL.

Q26
Multiple Choice

Determine the SQL scripts that correctly use the ALL clause to filter rows based on a condition in PostgreSQL.

Q27
Multiple Choice

Identify the SQL scripts that correctly use the EXISTS clause with an IN operator in PostgreSQL.

Q28
Multiple Choice

Select the SQL scripts that correctly use the ANY clause to compare values across multiple columns in PostgreSQL.

Q29
Multiple Choice

Determine the SQL scripts that correctly use the ALL clause to compare values in correlated subqueries in PostgreSQL.

Q30
Multiple Choice

Identify the SQL scripts that correctly use the EXISTS clause to filter rows in nested subqueries in PostgreSQL.