SUM

Description

Aggregate function.

The SUM() function calculates the sum of a set of values.

Note: NULL values are not counted.

Syntax

  1. > SUM(expr)

Arguments

ArgumentsDescription
exprAny expression

Returned Value

Returns the sum of expr. A double if the input type is double, otherwise integer.

If there are no matching rows, SUM() returns NULL.

Examples

  1. > drop table if exists tbl1,tbl2;
  2. > create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);
  3. > insert into tbl1 values (0,1,1,7,"a");
  4. > insert into tbl1 values (0,1,2,8,"b");
  5. > insert into tbl1 values (0,1,3,9,"c");
  6. > insert into tbl1 values (0,1,4,10,"D");
  7. > insert into tbl1 values (0,1,5,11,"a");
  8. > insert into tbl1 values (0,1,6,12,"c");
  9. > select sum(col_1c) from tbl1;
  10. +-------------+
  11. | sum(col_1c) |
  12. +-------------+
  13. | 21 |
  14. +-------------+
  15. > select sum(col_1d) as c1 from tbl1 where col_1d < 13 group by col_1e order by c1;
  16. +------+
  17. | c1 |
  18. +------+
  19. | 8 |
  20. | 10 |
  21. | 18 |
  22. | 21 |
  23. +------+

Constraints

Currently, MatrixOne doesn’t support select function() without from tables.