Impala AnalysisException:HAVING子句中不支持子查询

时间:2019-02-12 17:47:05

标签: impala

我有一个查询,我在其中选择目标主机名(与用户代理字符串匹配),并根据使用Impala的不同srchostname进行分组。

select desthostname
from proxy_table 
where useragentstring = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/538.1 (KHTML, like Gecko) Google Earth Pro/7.3.2.5491 Safari/538.1"
group by desthostname
having count(*) = (select count(distinct srchostname) from proxy_table);

但是我遇到了错误: AnalysisException: Subqueries are not supported in the HAVING clause.

您知道我该如何解决吗?

1 个答案:

答案 0 :(得分:1)

运行此:

select desthostname from
(select desthostname,count(*) as cnt
from proxy_table 
where useragentstring = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/538.1 (KHTML, like Gecko) Google Earth Pro/7.3.2.5491 Safari/538.1"
group by desthostname) A where A.cnt in (select count(distinct srchostname) from proxy_table);