Subqueries · SQL SQL

Explain the concept of a derived table (also known as an inline view) and state where it must be placed in a SQL query.

Practice question from Subqueries (SQL SQL), with the correct answer and a step-by-step solution.

medium · Subjective · Q-94564E

Explain the concept of a derived table (also known as an inline view) and state where it must be placed in a SQL query.

Answer: A derived table is a subquery used within the FROM clause of a SELECT statement that acts as a temporary table for the duration of the query execution. Because it resides in the FROM clause, it must always be assigned a correlation name or table alias so the outer query can reference its columns.

Solution

A derived table is a subquery placed in the FROM clause. It must be treated like any other table source, which requires assigning it an alias using the AS keyword so that outer clauses can query its columns.

More from Subqueries

All of Subqueries

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed