查询在impala中不起作用

p5cysglq  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(327)
(SELECT CONCAT('ABCDE',SUM((SELECT MAX(id) FROM optigo_data.admin_userdetails LIMIT 1)+1)))

以上是在mysql中工作,但它不是在 Impala /Hive工作,请帮助我。
错误:不支持子查询。

crcmnpdw

crcmnpdw1#

这个错误的原因是impala只支持from和where子句中的子查询。我认为这将是 Impala 的等价物:

SELECT
CONCAT('ABCDE',cast(SUM(t.value+1) as string))
from 
    (SELECT MAX(cast(id as int)) as value 
    FROM optigo_data.admin_userdetails LIMIT 1) as t

但是,假设您的目标是生成一个包含最高id+1的字符串,那么查看查询时,一个更简单的解决方案是:

SELECT
CONCAT('ABCDE',cast(MAX(cast(id as int)+1) as string))
FROM optigo_data.admin_userdetails

如果我的假设不正确,请纠正我。你可以放下枪 cast as int 如果 id 已为数字格式。

相关问题