2017-02-28 54 views
0
(SELECT CONCAT('ABCDE',SUM((SELECT MAX(id) FROM optigo_data.admin_userdetails LIMIT 1)+1))) 

上面是在Mysql中工作,但它不在Impala/Hive中工作,請幫助我。查詢不在Impala中工作

Error: sub query is not supported.

回答

0

此錯誤的原因是Impala僅支持FROM和WHERE子句中的子查詢。 我認爲這將是黑斑羚相當於:

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 

如果我的假設不正確,請糾正我。如果id已經是數字格式,則可以刪除cast as int

+1

感謝它的工作! –