首先我使用了查询:
select name
from tab1
where id in (select id
from (select id,count(id) as a
from tab2
group by id
order by a desc limit 1) ;
我开始知道在蜂巢中选择内部选择是不可能的。 所以我用变量修改了它。
set var1= select count(id) as a from tab2 group by id order by a desc limit 1;
select name from tab1 group by name having count(id)='${hiveconf:var1}';
但是在'${hiveconf:var1}'
的位置,查询被替换并再次出现相同的错误。
有没有办法做到这一点?
答案 0 :(得分:0)
select t1.name
from tab1 t1
join (select id
,count(*) as cnt
from tab2
group by id
order by cnt desc
limit 1
) t2
on t2.id = t1.id