More Than One Column After COMPUTE BY

Listing more than one column after the keyword BY breaks a group into subgroups and applies the specified row aggregate function at each level of grouping. For example, the following query finds the sum of the prices of psychology books from each publisher:

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

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                      

(7 row(s) affected)