user1309258
user1309258

Reputation: 89

Hive unique string count

I have a column of stings in a Hive table and I want to count the number of occurrences of each string in this column. How can I do that?

Upvotes: 0

Views: 3790

Answers (2)

dilshad
dilshad

Reputation: 754

Query that I think is correct:

SELECT columnA,columnB,COUNT(distinct column C)
from table_name
group by columnA,columnB

Is this correct? SQL is fine too.

Upvotes: 0

Martin Atkins
Martin Atkins

Reputation: 74249

It sounds like you need to group by the column and then count the number of items in each group. Something like this:

SELECT somecolumn, count(1) AS count
FROM sometable
GROUP BY somecolumn

Upvotes: 3

Related Questions