26 April 2012

How to Use Syntax - Compute By

Yaitu Menambahkan 1 row yang berisi total pada setiap aggregate function yang digunakan.
hanya data dipisahkan pada result set yang berbeda.

-----start-----
SELECT title = CONVERT(char(20), title), type, price, advance
FROM titles
WHERE ytd_sales IS NOT NULL
 AND type LIKE '%cook%'
 ORDER BY type DESC
COMPUTE AVG(price), SUM(advance) BY type
COMPUTE SUM(price), SUM(advance)
-----end-----