当我尝试获取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
谁能帮我看看错误在哪里?
您的括号在多个地方不平衡。使用这个版本:
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