当我像这样使用嵌套的select-in-hive时
Select
a.month,
a.day,
sum(a.pv)/count(a.*)
from
(Select month,day, remote_addr,count(1) as pv
from ods_weblog_detail group by remote_addr,month,day) as a;
它返回错误消息:“tok\u allcolref在当前上下文中不受支持”。
但当我分别选择月、日和总和(a.pv)/计数(a*)时,如下所示:
Select
sum(a.pv)/count(a.*)
from
(Select month,day, remote_addr,count(*) as pv from ods_weblog_detail group by remote_addr,month,day) as a;
或者这个:
Select
a.month,a.day
from
(Select month,day, remote_addr,count(*) as pv
from
ods_weblog_detail
group by remote_addr,month,day) as a;
两种说法都给了我正确的答案。那么为什么我不能在一个语句中同时选择这三个(a.month,a.day和sum(a.pv)/count(a.*)?谢谢!!!
1条答案
按热度按时间4si2a6ki1#
查询缺少
group by
.查询也可以简化如下。