我可以在 Hive 中嵌套具有不同条件的 select
吗?例如
如果我有以下两个 Hive 查询:
select percentile(x, 0.95)
from t1
where y = 1;
select percentile(x, 0.95)
from t1
where y = 2;
我可以在一个查询中选择上面的两个百分位数 - 类似于(它不起作用):
select
(select percentile(x, 0.95)
from t1
where y = 1),
(select percentile(x, 0.95)
from t1
where y = 2)
from t1;
最佳答案
您可以使用UNION ALL
来完成此操作,例如:
select * from
(select percentile(x, 0.95)
from t1
where y = 1
union all
select percentile(x, 0.95)
from t1
where y = 2) x;
关于hive - Hive 中的嵌套选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14512521/