我想创建一个包含3列的hive表。让我们说,id,average,incharge。 id和average的值在表格中,首先是'。对于incharge列,我需要在表' second'上执行查询。我试过这个但是失败了
create table third(
ID INT,
AVERAGE INT,
INCHARGE STRING
)
from first f
insert into table third select
f.id,
f.average,
from ( select second.incharge where second.k_id == f.id limit 1)
任何线索都会非常有用
答案 0 :(得分:1)
FROM (
SELECT
f.id ,
f.average
FROM
FIRST f ) x JOIN
(
SELECT
s.incharge ,
s.sid
FROM
second s ) y ON y.sid = x.id
INSERT
OVERWRITE TABLE third
SELECT
x.id ,
x.average ,
y.incharge