Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

How do I count shortcodes from row in hive?

New Contributor

I have a table which consists of eight column such as A,B,C,....H. Each column have some shortcodes such as U,V,W randomly.Now I need to count the no of U,V,W from each row.Some columns may have null or unknown value also.

Here is a demo:


Here I need to use HiveQL.


@PRIYATAM SAHA hm, I'm not sure if this is possible with SQL at all, since SQL works on a column basis. You could try reading the dataset into Apache Spark and then counting the values in the matrix like that. Check this question which seems similar to yours:

You load the table into Spark using a HiveContext and then you can work on it using Spark functions. Try that out perhaps and let us know how you get on.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.