SQL 错误:无关的输入 ')' 期望 AS 接近 '<EOF>'

问题描述 投票:0回答:1

当我尝试获取month_diff时收到以下错误

extraneous input ')' expecting AS near '<EOF>'

这是SQL代码

months_between((cast(min(bs.cpd_dt)) as date), cast(bs.first_prd_cpd_dt as date)) as month_diff

谁能帮我看看错误在哪里?

sql date hive casting
1个回答
0
投票

您的括号在多个地方不平衡。使用这个版本:

months_between(
    cast(min(bs.cpd_dt) as date),
    cast(bs.first_prd_cpd_dt as date)
) as month_diff

或者,作为单行:

months_between(cast(min(bs.cpd_dt) as date), cast(bs.first_prd_cpd_dt as date)) as month_diff
© www.soinside.com 2019 - 2024. All rights reserved.