next up previous
Next: Views Up: SQL Previous: Test for the Absence

Derived Relations

  1. SQL-92 allows a subquery expression to be used in the from clause.
  2. If such an expression is used, the result relation must be given a name, and the attributes can be renamed.
  3. 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

Osmar Zaiane
Fri May 22 19:39:12 PDT 1998