简体   繁体   中英

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

Please help on the query part - in 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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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