中的数字进行比较
我有一个表,我有一个可空blob字段类型(SQL SERVER 2005)用于存储图像。所以我有以下情况:
select count (*) from table where image_field is null
返回180000行图像。
select count (*) from table where image_field is not null
返回没有图像的3600000行。
如果我使用select count (*) from table
,我没有3780000行(3600000 + 180000),但少一点。
谁能解释一下为什么会这样?
有人添加或删除了几行?
试
Select Count(*) total,
Sum(case when When image_field is null Then 1 Else 0 End) nullCount,
Sum(case when When image_field is not null Then 1 Else 0 End) notNulCount
From table
并将这些数字与单个查询