you should be able to use the:
1、ROLLUP operation to produce subtotal values
2、CUBE operation to produce cross-tabulation values
3、GROUPING function to identify the row values created by ROLLUP or CUBE
4、GROUPING SETS to produce a single result set
原文:http://blog.51cto.com/3938853/2159858