Count NULL Values from multiple columns with SQL

后端 未结 5 1064
天命终不由人
天命终不由人 2020-12-15 20:44

I have 3 columns let say A, B, and C. I need to count the NULL values in each column.

For example:



        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 20:52

    select
        sum(case when a is null then 1 else 0 end) as a_null_count,
        sum(case when b is null then 1 else 0 end) as b_null_count,
        sum(case when c is null then 1 else 0 end) as c_null_count
    from table
    

提交回复
热议问题