Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

like image 894
Ram Avatar asked Nov 01 '25 17:11

Ram


1 Answers

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

enter image description here

like image 135
Mikhail Berlyant Avatar answered Nov 04 '25 20:11

Mikhail Berlyant