how to count multiple column values in hive?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

how to count multiple column values in hive?



In hive table i have eight household members data. Columms are:


statusmem1,
statusmem2,
statusmem3,
statusmem4,
statusmem5,
statusmem6,
statusmem7,
statusmem8



In these columns the data mentioning the status of a houshold member like if status of statusmem1 is H(head) or W(spouce) etc.



Some of the columns have null values.
So, the question is how do I count number of values in those eight column. Not consider the null values.



So just tell me how can I count the multiple column values by excluding the null values in hive?




1 Answer
1



Count() does not count nulls, so, to count not null values, just use count(column):


Count()


select
count(statusmem1) as statusmem1_cnt,
count(statusmem2) as statusmem2_cnt,
count(statusmem3) as statusmem3_cnt,
count(statusmem4) as statusmem4_cnt,
count(statusmem5) as statusmem5_cnt,
count(statusmem6) as statusmem6_cnt,
count(statusmem7) as statusmem7_cnt,
count(statusmem8) as statusmem8_cnt
from tabele;






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Hystrix command on request collapser fallback