gpt4 book ai didi

sql - 带有多个子查询的 Hive

转载 作者:行者123 更新时间:2023-12-04 18:01:54 25 4
gpt4 key购买 nike

我试图在 where 子句中运行多个子查询,但出现以下错误。是否意味着 Hive 不支持它?如果没有,是否有不同的方式来编写下面的查询?

执行配置单元查询时出错:OK FAILED:SemanticException [错误 10249]:第 14 行不支持的子查询表达式“adh”:仅支持 1 个子查询表达式。

select
first_name,
last_name,
salary,
title,
department
from
employee_t1 emp
where
emp.salary <= 100000
and (
(emp.code in (select comp from history_t2 where code_hist <> 10))
or
(emp.adh in (select comp from sector_t3 where code_hist <> 50))
)
and department = 'Pediatrics';

最佳答案

我同意戈登。使用连接,您可以尝试以下查询(未测试):

 select
a.first_name,
a.last_name,
a.salary,
a.title,
a.department
from
(Select * from employee_t1 where
emp.salary <= 100000
and department = 'Pediatrics') a
left outer join (select comp from history_t2 where code_hist <> 10) b
on a.code = b.comp
left outer join (select comp from sector_t3 where code_hist <> 50) c
on a.adh = c.comp
where b.comp is not null
or c.comp is not null
;

关于sql - 带有多个子查询的 Hive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33899935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com