Sum with 'group by cude' : SUM « Aggregate Functions « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> select         owner,
  2                 tablespace_name,
  3                 sum(bytes)/(1024*1024) total_meg
  4      from dba_extents
  5      where rownum < 50
  6      group by cube (owner,tablespace_name)
  7      /

OWNER                          TABLESPACE_NAME                 TOTAL_MEG
------------------------------ ------------------------------ ----------
                                                                       4
                               SYSTEM                                  4
SYS                                                                    4
SYS                            SYSTEM                                  4








12.8.SUM
12.8.1.SUM(x) adds all the values in x and returns the total.
12.8.2.Sum with 'group by cude'
12.8.3.Sum with null value
12.8.4.Sum column for a certain time period
12.8.5.Sum() function and having clause
12.8.6.Sum salary group by department number