I want to count just the null values in a specific column and all the null values in another specific column, however i want my result to have both of these results shown in one table.
Here is what i have so far:
Select Count(*) as 'Column1Count', Count(*) as 'Column2Count'
from table1
开发者_Python百科 Where column1 is null
and column2 is null
please help
This should work :
select
(select count(*) from table1 where column1 is null) as 'Column1Count',
(select count(*) from table1 where column2 is null) as 'Column2Count';
You could use a case for that:
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
精彩评论