我正在面对Analytics Exception,同时要将内部数据集合并。
查询:
Select key,days
FROM
(
Select key
FROM sls where id =14004
) AS first
JOIN
(
Select seckey ,days
FROM
(
Select seckey , MAX(opp_days) As days from sls_daily Where id=14004 Group By key
) As f
JOIN
(
Select key,est,cls,days from sls_daily Where dw_cid=14004
) As s
ON f.days = s.days AND f.key= s.key
) AS second
ON second.seckey = first.key
异常:
AnalysisException:第15行中的语法错误:)AS first ^遇到: FIRST预期:IDENTIFIER CAUSED BY:异常:语法错误
错误的原因是什么。
答案 0 :(得分:2)
尽量避免reserved
中的SQL
字。
试试这个
Select `key`,`days`
FROM
(
Select `key`
FROM sls where id =14004
) AS `first`
JOIN
(
Select seckey ,`days`
FROM
(
Select seckey , MAX(opp_days) As `days` from sls_daily Where id=14004 Group By key
) As f
JOIN
(
Select `key`,est,cls,`days` from sls_daily Where dw_cid=14004
) As s
ON f.`days` = s.`days` AND f.`key`= s.`key`
) AS `second`
ON `second`.seckey = `first`.`key`