我有一个查询
with ex as (
select z.num number, car.id as id, car.make as make, car.model, 'vehicles' as type from mytable mt LATERAL VIEW EXPLODE(mt.vehicles) vehiclestbl as honda
where car.working = true
union all
select z.num number, plane.id as id, plane.make as make, plane.model, 'flights' as type from mytable mt LATERAL VIEW EXPLODE(mt.flights) flightstbl as wings
where plane.active = true
union all
select z.num number, train.id as id, train.make as make, train.model, 'departures' as type from mytable mt LATERAL VIEW EXPLODE(mt.departures) departurestbl as wheels
where wheels.active = true
)
select ex0.*, 1499 as cost, model as location
from ex ex0
where mycolumn = 15
最终结果看起来像这样
number id make model type cost location
323 abc make1 model1 type1 1499 modelLoc1
329 xyz make2 model2 type2 1499 modelLoc2
984 lks make3 model3 type3 1499 modelLoc3
我正在尝试将“数字”列与另一个外部表连接。每当我添加一个
INNER JOIN myothertable mot on mot.id = ex_id;
我收到“无法识别附近的输入”错误
最佳答案
在CTE中,该列称为number
,因此我希望查询看起来像这样:
select ex0.*, 1499 as cost, model as location
from ex ex0 inner join
myothertable mot
on mot.id = ex0.number;
where mycolumn = 15;
关于hadoop - 配置单元SQL连接语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48406700/