COUNT
Description
Aggregate function.
The COUNT() function calculates the number of records returned by a select query.
Note: NULL values are not counted.
Syntax
1. > COUNT(expr)
Arguments
| Arguments | Description |
|---|---|
| expr | Any expression.This may be a column name, the result of another function, or a math operation. * is also allowed, to indicate pure row counting. |
Returned Value
Returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement. The result is a BIGINT value.
If there are no matching rows, COUNT() returns 0.
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");
10. > select count(col_1b) from tbl1;
11. +---------------+
12. | count(col_1b) |
13. +---------------+
14. | 6 |
15. +---------------+
17. > select count(*) from tbl1 where col_1d<10;
18. +----------+
19. | count(*) |
20. +----------+
21. | 3 |
22. +----------+
Constraints
Currently, MatrixOne doesn’t support select function() without from tables.
