帮忙看一条sql 谢谢了
select currentYear
from yyxt.dbo.t_d_Yield_SoilSurvey where currentYear
between (select min(currentYear) from yyxt.dbo.t_d_Yield_SoilSurvey)
and ((select min(currentYear) from yyxt.dbo.t_d_Yield_SoilSurvey)+4)
================
这条语句在sqlServer上运行都可以
因为现在要改成sybase数据库
所以就报错了 主要是+4这里出错了 sybase说 不允许从varchar到int的转换
如果我把4换成'4' 结果就是: 比如currentYear='2009'的话 结果就是20094
我都不知道怎么办呢
别人说用CAST(min(currentYear) AS INT) + 1可以 但是好像不适合我这条语句
[解决办法]
select currentYearfrom yyxt.dbo.t_d_Yield_SoilSurvey where CAST(currentYear AS INT) between (select CAST(min(currentYear) AS INT) from yyxt.dbo.t_d_Yield_SoilSurvey) and ((select CAST(min(currentYear) AS INT)+4 from yyxt.dbo.t_d_Yield_SoilSurvey))