PostgreSQL Database Quiz Questions

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

A subquery in PostgreSQL can be used in the SELECT clause of an SQL statement.

Q2
True / False

Subqueries in PostgreSQL can only return a single value.

Q3
True / False

In PostgreSQL, a subquery can be used within a WHERE clause to filter records.

Q4
True / False

In PostgreSQL, you can use a subquery in the FROM clause to create a temporary table for the main query.

Q5
True / False

PostgreSQL does not support correlated subqueries.

Q6
True / False

A subquery in PostgreSQL cannot use the ORDER BY clause.

Q7
True / False

In PostgreSQL, a subquery can be used with the EXISTS operator to check for the existence of rows.

Q8
True / False

Subqueries in PostgreSQL can be nested up to an unlimited number of levels.

Q9
True / False

In PostgreSQL, a subquery used in the SELECT clause must always return a single row.

Q10
True / False

In PostgreSQL, using subqueries can sometimes be optimized by the query planner to improve performance.

Q11
Single Choice

What is a subquery in PostgreSQL?

Q12
Single Choice

Which of the following is a correct syntax for a subquery in PostgreSQL?

SQL Code
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
Q13
Single Choice

Can subqueries in PostgreSQL return more than one column?

Q14
Single Choice

In PostgreSQL, which subquery type is used when the subquery is correlated with the outer query?

Q15
Single Choice

What is the result of the following PostgreSQL query?

SQL Code
SELECT name FROM employees WHERE department_id IN (SELECT id FROM departments WHERE name = 'HR');
Q16
Single Choice

Which clause is typically used with a subquery in PostgreSQL to filter rows based on the results of the subquery?

Q17
Single Choice

What will the following PostgreSQL query return?

SQL Code
SELECT name FROM employees WHERE salary = (SELECT MAX(salary) FROM employees);
Q18
Single Choice

Which of the following is true about using a subquery in the FROM clause in PostgreSQL?

Q19
Single Choice

What will the following PostgreSQL query return?

SQL Code
SELECT department, (SELECT COUNT(*) FROM employees e WHERE e.department_id = d.id) AS employee_count
FROM departments d;
Q20
Single Choice

In PostgreSQL, what is the purpose of a scalar subquery, and how is it typically used in a SELECT clause?

SQL Code
SELECT name, (SELECT AVG(salary) FROM employees) AS avg_salary FROM employees;
Q21
Multiple Choice

Which SQL queries correctly utilize a subquery to find the highest salary from the employees table?

Q22
Multiple Choice

Which SQL queries correctly use subqueries to filter results in the orders table?

Q23
Multiple Choice

Determine which SQL queries correctly apply subqueries to return employees who earn more than the department average salary.

Q24
Multiple Choice

Which SQL queries correctly use subqueries to identify products with sales above the average?

Q25
Multiple Choice

Identify SQL queries that correctly utilize subqueries to return customers with more than one order.

Q26
Multiple Choice

Which SQL queries correctly use subqueries to return the names of employees who work in departments with more than 10 employees?

Q27
Multiple Choice

Identify the SQL queries that correctly use subqueries to find departments where the average salary is above $50,000.

Q28
Multiple Choice

Which SQL queries correctly use subqueries to return products that are more expensive than the average price in their category?

Q29
Multiple Choice

Determine the SQL queries that correctly use subqueries to find employees who earn more than any other employee in their department.

Q30
Multiple Choice

Which SQL queries correctly use subqueries to return customer orders that exceed the average order amount?