# NumericCount - 脚本函数

NumericCount() 用于返回表达式中数值的数量，该数量由 group by 子句定义。

语法：

NumericCount (NumericCount ( [ distinctdistinct ] expr ] expr))

返回数据类型： 整数

参数：

NumericCount 参数

| 参数 | 说明 |
| --- | --- |
| expr | 表达式或字段包含要度量的数据。 |
| distinct | 如果在表达式前出现单词 distinct，则将忽略所有重复值。 |

示例和结果：

将示例脚本添加到文档并运行。然后，至少要将结果列中列出的字段添加到文档中的表格才能查看结果。

示例 1:

`Temp:` `LOAD * inline [` `Customer|Product|OrderNumber|UnitSales|UnitPrice` `Astrida|AA|1|4|16` `Astrida|AA|7|10|15` `Astrida|BB|4|9|9` `Betacab|CC|6|5|10` `Betacab|AA|5|2|20` ` Betacab|BB|||  25  ` `Canutility|AA|||15` `Canutility|CC| ||19` `Divadip|CC|2|4|16` `Divadip|DD|7|1|25` `] (delimiter is '|');` `NumCount1:` `LOAD  Customer,NumericCount(OrderNumber) as NumericCountByCustomer Resident Temp Group By Customer;
`

示例 1 结果

| 客户 | NumericCountByCustomer |
| --- | --- |
| Astrida | 3 |
| Betacab | 2 |
| Canutility | 0 |
| Divadip | 2 |

示例 2:

`LOAD NumericCount(OrderNumber) as TotalNumericCount Resident Temp;`

第二个语句指定：  
TotalNumericCount  
7

示例 3:

前提是 Temp 表格像之前的示例一样加载：

`LOAD NumericCount(distinct OrderNumber) as TotalNumericCountDistinct Resident Temp;`

TotalNumericCountDistinct   
6  
由于有一个 OrderNumber 进行了复制，因此结果是 6 个特殊值。