Sub Query

📝 Sub Query

Total Questions: 5
Click an answer to select it, then click "Check Answers" to see your results.
Question 1

What is the primary purpose of a **subquery** in SQL?

A.

A) To replace the JOIN operation entirely

B.

B) To nest a query inside another query, with the inner query executing first to provide data

C.

C) To create a temporary table that persists in the database

D.

D) To speed up query execution by eliminating WHERE clauses

Question 2

What does a **scalar subquery** return when used in a WHERE clause?

A.

A) Multiple rows and columns

B.

B) A list of values for use with IN or NOT IN

C.

C) A single value that can be compared with operators like >, <, or =

D.

D) An error because scalar subqueries cannot be used in WHERE

Question 3

What is the primary purpose of using a subquery in the **HAVING** clause?

A.

A) To compare aggregated values of groups against a scalar value

B.

B) To filter individual rows before grouping

C.

C) To join multiple tables within the group

D.

D) To sort the grouped results

Question 4

What is the primary purpose of using a subquery in the **select clause**?

A.

A. To filter rows in the outer query before execution

B.

B. To compute a single value per row of the outer query using correlated references

C.

C. To join multiple tables without aliases

D.

D. To group results across the entire dataset

Question 5

What is the primary requirement for a subquery placed in the **FROM clause**?

A.

A) It must return a single scalar value

B.

B) It must return a complete table structure with rows and columns

C.

C) It must contain only aggregate functions

D.

D) It must reference the outer query's tables

Quiz Complete!

Score: 0 / 5