简体   繁体   English

如何获取 bigquery 中每列的 null 值计数/百分比

[英]How to get the null value count/percentage for each columns in bigquery

TableName = 'Header'表名 = '表头'

As per below table details Reg_nbr has no null values so in output it is 0, Reg_name is having 3 null values out of 6 records so output it is 50 and Reg_code has only null values so output it is 100根据下表详细信息,Reg_nbr 没有 null 值,所以在 output 中它是 0,Reg_name 在 6 条记录中有 3 个 null 值,所以 output 是 50,Reg_code 只有 null 值,所以 883343780 是 88334371

Please help on the query part - in bigquery请在查询部分提供帮助 - 在 bigquery 中

在此处输入图像描述

Consider below approach考虑以下方法

select 
  100 * countif(Reg_nbr is null) / count(1) as Reg_nbr,
  100 * countif(Reg_Name is null) / count(1) as Reg_Name,
  100 * countif(Reg_Code is null) / count(1) as Reg_Code
from your_table          

if applied to sample data in your question - output is如果应用于您问题中的示例数据 - output 是

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM