Code:
select rep,cust,amount
from orders
order by rep,cust
compute sum(amount) by rep,cust
compute sum(amount),avg(amount) by rep;
From a book by Groff and Weinberg "SQL" BTW a superb book!
I am sure the SQL shown works somewhere...probably Oracle.
Doesn't work with MySQL!
HMM! maybe I need to specify innodb!