count() 函数
count()
返回每个输入表中的记录数。
该函数同时计数 null 和非 null 记录。
空表
count()
对空表返回 0
。要在数据中保留空表,请为以下函数设置以下参数
函数 | 参数 |
---|---|
filter() | onEmpty: "keep" |
window() | createEmpty: true |
aggregateWindow() | createEmpty: true |
函数类型签名
(<-tables: stream[A], ?column: string) => stream[B] where A: Record, B: Record
有关更多信息,请参阅 函数类型签名。
参数
column
要在其中计数值的列,并存储总计数。
tables
输入数据。默认为管道转发数据 (<-
)。
示例
计数每个输入表中的记录数
import "sampledata"
sampledata.string()
|> count()
计数具有特定值的记录数
- 使用
filter()
按要计数的特定值过滤数据。 - 使用
count()
计数表中的行数。
import "sampledata"
data =
sampledata.int()
|> filter(fn: (r) => r._value > 10)
data
|> count()
此页面是否对您有帮助?
感谢您的反馈!