I want to count values similar in a map where key would be the value in the Hive table column and the corresponding value is the count.
For example, for the table below:
+-------+-------+
| Col 1 | Col 2 |
+-------+-------+
| Key1 | Val1 |
| Key1 | Val2 |
| Key2 | Val1 |
+-------+-------+
So the hive query should return something like
Key1=2
Key2=1
It looks like you are looking for a simple group by.
SELECT Col1, COUNT(*) FROM Table GROUP BY Col1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With