(1) Get names and ids of customers and agents along with
total dollar sales for that pair. Order the result
from largest to smallest total sales. Also retain
only those pairs for which total dollar sales is
at least 900.00.
SQL> select c.cname, c.cid, a.aname, a.aid, sum(o.dollars)
from customers c, orders o, agents a
where c.cid = o.cid and o.aid = a.aid
group by c.cname, c.cid, a.aname, a.aid
having sum(o.dollars) >= 900.00
order by 5 desc;
CNAME CID ANAME AID SUM(O.DOLLARS)
------------- ---- ------------- --- --------------
Allied c003 Brown a03 2208
Tiptop c001 Otasi a05 1440
Tiptop c001 Smith a01 900