关于 SequoiaDB
快速入门
安装
基本操作
数据模型
SQL引擎
S3引擎
系统架构
数据库管理
连接器
驱动
参考手册
故障排除
SAC 管控中心
Web服务
版本信息
聚集函数
用于计数,返回匹配指定字段名的条数
count(field_name) as <alias_name>
参数名 | 参数类型 | 描述 | 是否必填 |
---|---|---|---|
field_name | string | 字段名 | 是 |
alias_name | string | 别名 | 否 |
Note:
使用 count 函数对字段名计数,必须使用别名
返回对指定字段的计数
集合foo.bar中记录如下
{ "name": "tom", "age": 10 } { "name": "sam", "age": 11 } { "name": "james" }
通过 age 字段统计集合 foo.bar 中的记录数
> db.exec("select count(age) as 数量 from foo.bar") { "数量": 3 } Return 1 row(s).
Note:
在 SQL 中,字段缺失则值会为 null,在统计时作为一条记录计入。
对集合 foo.bar 中 age 字段进行计数
> db.exec("select count(age) as 数量 from foo.bar where age isnot null") { "数量": 2 } Return 1 row(s).