SQL-92 allows a subquery expression to be used in the from clause.
If such an expression is used, the result relation must be given a name, and the attributes can be renamed.
Find the average account balance of those branches where the average account balance is greater than $1,000.
select bname, avg-balance
from (select bname, avg(balance)
from account
group by bname)
as result(bname, avg-balance)
where avg-balance > 1000
One thought on “SQL: Derived Relations”