Hive,SQL:为Hive表中的100多列中的每一列返回COUNT个NULL值

时间:2016-09-20 20:13:54

标签: sql hive

什么是为Hive表中的100多列中的每一列返回COUNT个NULL值的SQL代码?

1 个答案:

答案 0 :(得分:2)

在SQL中它将是

 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 z is null then 1 else 0 end) as z_null_count
 FROM table