选择内部选择在蜂巢中不起作用

时间:2014-11-25 13:20:26

标签: sql hive hiveql

下一个查询可以在oracle中运行,但不能在hive中运行:

select user_key,(sum(333)/(select 10 from table.dual)) calculationResult from user_usage_table group by user_key;

我期望的结果:

user_key    calculationResult
DB-_app6_61_28fba6e2f0_12d  2930.4
DB-_app6_61_28fba6e2f0_171  2930.4
DB-_app6_61_28fba6e2f0_1b5  2930.4
DB-_app6_61_28fba6e2f0_69   2930.4
DB-_app6_61_28fba6e2f0_e9   2930.4

我能得到什么:

FAILED: ParseException line 1:33 cannot recognize input near 'select' '10' 'from' in expression specification

如何在配置单元中应用此功能?

1 个答案:

答案 0 :(得分:1)

你的查询很奇怪。为什么不写:

select user_key, (sum(333) / 10) as calculationResult
from user_usage_table
group by user_key;

这应该适用于Oracle和hive。