我正在尝试进行查询,以检查是否有行的薪水比该部门的薪水高 10000 ,但是当我尝试运行该行时,出现此错误:
失败:ParseException行3:39在表达式规范的“''附近不匹配输入'SELECT'
这是我使用
的查询set AVERAGES ='SELECT ROLE, AVG(AnnualSalary) From Salaries GROUP BY ROLE';
SELECT ROLE, AVG(AnnualSalary) FROM Salaries
GROUP BY ROLE, AnnualSalary HAVING AnnualSalary > ('${hiveconf:AVERAGES}' + 10000);
答案 0 :(得分:0)
当前,Hive不支持将查询结果存储到变量中。
您可以使用窗口功能来实现此目的。
select * from
( select *,
avg(AnnualSalary) over(partition by ROLE) role_avg
from
Salaries
) a
where
AnnualSalary > role_avg+10000