Sunday 15 May 2011

hadoop - How display two fields sums in the same query in HIve -



hadoop - How display two fields sums in the same query in HIve -

i have hive table next fields:

id string , x string

where x can have values such 'c'.

i need query display number of rows column x contains value 'c' , number of rows x has values other 'c'.

id | count(x='c') | count(x<>'c') ---|--------------|-------------- 1 | 3 | 7

i don't know if it's possible.

you can seek :

select sum(if(x='c',1,0)), sum(if(x!='c',1,0)) table_name;

this print 2 columns. didn't understand id field in sample output.

hadoop count hive

No comments:

Post a Comment