Rollup()是group by 的一个扩展函数,可以用来求分组合计。下面是rollup结合Grouping进行统计的SQL
1 Select Decode(Grouping(col), 1, 'Total', col) As col, Count(*) 2 From testTable 3 Group By Rollup(col) 4 Order By col;