select bname, avg-balance from (select bname, avg(balance) from account group by bname) as result(bname, avg-balance) where avg-balance > 1000
from (select bname, avg(balance)
from account
group by bname)
as result(bname, avg-balance)
where avg-balance > 1000