2012-12-03 117 views
4

我使用下面的代碼,並獲得以下錯誤組採用蜂巢

 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 

錯誤我猜我使用GROUP BY當您使用group by不當

回答

7

,你無法選擇其他額外的領域。您只能選擇具有聚合功能的組密鑰。

有關更多信息,請參見hive group by

Related questions

代碼例如:

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

或組由乘法字段。

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

預計所有的列將被添加group by。 即使我面臨同樣的問題,但我設法解決這些問題。 您可以使用帶列名稱的collect_set以獲取輸出。例如 select d.searchpack,collect_set(d.context) from sampletable group by d.searchpack;