Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in group by using hive

Tags:

hive

I am using the following code and getting the error below

      select d.searchpack,d.context, d.day,d,txnid,d.config, c.sgtype from ds3resultstats d join       
     context_header c on (d.context=c.contextid) where (d.day>='2012-11-15' and d.day<='2012-11-25' and  c.sgtype='Tickler' and d.config like 
'%people%') GROUP BY d.context limit 10;
        FAILED: Error in semantic analysis: line 1:7 Expression Not In Group By Key d

I am guessing I am using the group by incorrectly

like image 876
megv Avatar asked Jan 14 '23 20:01

megv


1 Answers

when you use group by, you cannot select other additional field. You can only select group key with aggregate function.

See hive group by for more information.

Related questions.

Code example:

select d.context,count(*)
from ds3resultstats
...
group by d.context

or group by multiply fields.

select d.context, d.field2, count(*)
from ds3resultstats
...
group by d.context, d.field2
like image 96
pensz Avatar answered Feb 01 '23 00:02

pensz