0

I'm having difficulty pinning down the proper syntax to get a total I need from Oracle 11g. I need to produce a total based on values in column 2, independent of the values in column 1. I've tried several types of rollup, cube, grouping sets, but I keep getting totals for each grade level (values in column 1).

Here is the 'group by' without any subtotaling:

... sql select statement ...
...
GROUP BY grade, inc_count
ORDER BY grade

which produces

9     714
10    550
11    445
12    296

And here is my goal output:

9     714
10    550
11    445
12    296
      2005

Which permutation of rollup/group sets/or something else will get me to my goal output?

Brian Brock
  • 357
  • 2
  • 3
  • 18

2 Answers2

0

You could try doing a UNION ALL to this SELECT 'SUM', SUM(value) from TABLE

Nived
  • 1,804
  • 1
  • 15
  • 29
0

For the example you gave:

select grade, sum(cnt)
from t
group by cube(grade)
order by sum(cnt);

group by cube is "syntactic sugar" for:

group by grouping sets ((grade),())
Lennart - Slava Ukraini
  • 6,936
  • 1
  • 20
  • 32