2017-03-17 9 views
1

ファーストを選択内側のselectを使用して、私は、クエリを使用:はハイブ:

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 
+0

次のエラーが発生しました。エラー[10128]:まだサポートされていません。UDAF 'count'の場所 – Pragadeesh

+0

インナーセレクトの順番にポイントがありません。完全に取り除くだけです。 – Andrew

+1

@Andrew - それには「limit」が付属しています –