1

我在asp.net 网站上工作。我无法计算数据库 Sqlserverce 中特定 id 的唯一空值。假设我有一个名为 Alarm 的表

alarmid     date
1   12/12/2010  
2   Null
3   4/4/2010
5   12/05/2011
6   Null

在这里我需要找到空值的计数。即 2. 我使用 ISNULL 和 COUNT 函数,但它不起作用。如何查找空值计数。我试过 select count(date) ,其中日期为空。但不工作。请帮帮我。

4

2 回答 2

1

count(Null)不应该计算任何东西,但你可以给 count 函数提供别的东西。例如,1

select 
count(1) 
where date is null.
于 2011-09-08T05:07:24.780 回答
0

在 SQL Server 中,您可以做到这一点,希望它可以在 CE 中工作

SELECT count(isnull([date],0)) 作为总数

更新:这适用于 CE,以上仅适用于 SQL Server,因为 CE 不支持 isnull

select count(COALESCE(name ,1)) from test where name is null

于 2011-09-08T05:03:59.887 回答