You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL计算month_diff时报错:extraneous input ')' expecting AS near '<EOF>'

问题排查与修复

你的SQL代码报错原因是**cast函数的括号使用错误**:

原代码中cast(min(bs.cpd_dt)) as date部分多写了一个右括号,cast的正确语法是cast(表达式 as 数据类型),多余的括号破坏了语法结构,导致解析器无法识别,触发了extraneous input ')' expecting AS near '<EOF>'错误。

修正后的代码:

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

内容的提问来源于stack exchange,提问作者Mdick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 04:19:50