# NullCount - 脚本函数

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

语法：

NullCount (NullCount ( [ distinctdistinct ] expr ] expr))

返回数据类型： 整数

参数：

NullCount 参数

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

示例和结果：

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

示例和结果

| 示例 | 结果 |
| --- | --- |
| `Set NULLINTERPRET = NULL;`<br>`Temp:`<br>`LOAD  * inline [`<br>`Customer\|Product\|OrderNumber\|UnitSales\|CustomerID`<br>`Astrida\|AA\|1\|10\|1`<br>`Astrida\|AA\|7\|18\|1`<br>`Astrida\|BB\|4\|9\|1`<br>`Astrida\|CC\|6\|2\|1`<br>`Betacab\|AA\|5\|4\|2`<br>`Betacab\|BB\|2\|5\|2`<br>`Betacab\|DD\|\|\|`<br>`Canutility\|AA\|3\|8\|`<br>`Canutility\|CC\|NULL\|\|`<br>`] (delimiter is '\|');`<br>`Set NULLINTERPRET=;`<br>`NullCount1:`<br>`LOAD  Customer,NullCount(OrderNumber) as NullOrdersByCustomer Resident Temp Group By Customer;<br>`<br>` `<br><br>`LOAD NullCount(OrderNumber) as TotalNullCount Resident Temp;` | `Customer NullOrdersByCustomer`<br>`Astrida 0`<br>`Betacab 0`<br>`Canutility 1`<br><br>第二个语句指定：<br><br>`TotalNullCount`<br>`1`<br><br>在包含该维度的表格中，因为只有一条记录包含 NULL 值。 |