Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting in Hadoop Hive

Tags:

hadoop

hive

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
like image 596
divinedragon Avatar asked Apr 03 '12 14:04

divinedragon


1 Answers

It looks like you are looking for a simple group by.

SELECT Col1, COUNT(*) FROM Table GROUP BY Col1

like image 109
Steve Severance Avatar answered Nov 15 '22 09:11

Steve Severance