SemanticException [错误10025]:第1行:7表达式不在GROUP BY键' stock_symbol'

时间:2015-12-04 17:05:11

标签: hive hiveql

这是我的Hive查询:

select a.stock_symbol,a.stock_date,a.stock_price_open,a.stock_price_high,
       a.stock_price_low,a.stock_price_close,b.stock_symbol,
       MAX(b.stock_price_high), 
       MIN(b.stock_price_low) 
from YAHOO_STOCKS a
join YAHOO_STOCKS b
on  a.stock_symbol=b.stock_symbol
where b.stock_symbol=a.stock_symbol
   and b.stock_date > date_sub(a.stock_date,364)
   and b.stock_date <= a.stock_date
group by b.stock_symbol
order by a.stock_symbol,a.stock_date;

我收到此错误:

  

FAILED:SemanticException [错误10025]:第1行:7表达式不在GROUP BY键&#39; stock_symbol&#39;

请帮帮我。

1 个答案:

答案 0 :(得分:0)

无论何时使用UDF,都必须按所有其他列进行分组。

使用此查询:

select a.stock_symbol,a.stock_date,a.stock_price_open,a.stock_price_high,
       a.stock_price_low,a.stock_price_close,b.stock_symbol,
       MAX(b.stock_price_high), 
       MIN(b.stock_price_low) 
from YAHOO_STOCKS a
join YAHOO_STOCKS b
on  a.stock_symbol=b.stock_symbol
where b.stock_date > date_sub(a.stock_date,364)
   and b.stock_date <= a.stock_date
group by a.stock_symbol,a.stock_date,a.stock_price_open,a.stock_price_high,
       a.stock_price_low,a.stock_price_close,b.stock_symbol
order by a.stock_symbol,a.stock_date;