Using More Than One COMPUTE Clause

You can use different aggregate functions in the same statement by including more than one COMPUTE BY clause. Here's a query similar to the preceding one. It finds the sum of the prices of all psychology books, as well as the sum of the prices of psychology books by publisher:

SELECT type, pub_id, price
FROM titles
WHERE type = 'psychology'
ORDER BY type, pub_id, price
COMPUTE SUM(price) BY type, pub_id
COMPUTE SUM(price) BY type

type         pub_id price                      
------------ ------ -------------------------- 
psychology   0736   28.00                      
psychology   0736   31.96                      
psychology   0736   43.80                      
psychology   0736   79.96                      

                    sum
                    ==========================
                    183.72                     

type         pub_id price                      
------------ ------ -------------------------- 
psychology   0877   21.59                      

                    sum
                    ==========================
                    21.59                      
                    sum
                    ==========================
                    205.31                     

(8 row(s) affected)