Skip to main content
basil_paul
Silver ⭐️⭐️
Jan 6, 2019 6:52 PM UTC
Solved

How to find the count of NULL values in Hive

Query:

select 2gusage,count(2gusage) from demo group by 2gusage;

Output:

MID 765153

HIGH 18095461

LOW 119069472

NULL 25997075

I tried the below query to find the count of NULL values

Query

select count(*) from demo where 2gusage is 'NULL';

Output

0

Kindly help me out with the query to find the count of NULL values

Shu_ashu
Shu_ashuAnswer
Gold ⭐️⭐️⭐️
Jan 6, 2019 10:42 PM UTC
@Basil Paul

1.Try with below query:

select count(*) from demo where 2gusage is NULL;

2.If literal NULL is in your data for 2gusage column then use the below query:

select count(*) from demo where 2gusage = "NULL";

2 replies

Shu_ashu
Shu_ashuAnswer
Gold ⭐️⭐️⭐️
Jan 6, 2019 10:42 PM UTC
@Basil Paul

1.Try with below query:

select count(*) from demo where 2gusage is NULL;

2.If literal NULL is in your data for 2gusage column then use the below query:

select count(*) from demo where 2gusage = "NULL";

Translate
basil_paul
Silver ⭐️⭐️
Jan 8, 2019 11:39 AM UTC

@Shu . Thankyou so much . Second query worked

Translate