我想只计算特定列中的空值和另一列中的所有空值 特定列,但我希望我的结果在一个表中显示这两个结果。
这是我到目前为止所拥有的:
Select Count(*) as 'Column1Count', Count(*) as 'Column2Count'
from table1
Where column1 is null
and column2 is null
请帮助
答案 0 :(得分:4)
这应该有效:
select
(select count(*) from table1 where column1 is null) as 'Column1Count',
(select count(*) from table1 where column2 is null) as 'Column2Count';
答案 1 :(得分:1)
您可以使用案例:
select sum(case when Column1 is null then 1 end) as Col1Count
, sum(case when Column2 is null then 1 end) as Col2Count
from table1