如图,RGWEK和Z1WEK是数据库字段,值为年+第几周的日期比如202244,且每行 一一对应,p_numberEditor0是一个入参,是一个固定数字。我要筛选RGWEK<=Z1WEK+p_numberEditor0的数据,应该怎么写呢,还要考虑一点就是比如2022年有52周,那Z1WEK是202252,加了1的话应该变成202301才对
where 1=1
${if(len(p_numberEditor0)=0,"",if(p_numberEditor0>52,"and RGWEK<='"+CONCATENATE(Z1WEK+1,"01")+"'","RGWEK<='"+CONCATENATE(Z1WEK,p_numberEditor0)+"'"))}
RGMON<=Z1WEK+"p_numberEditor0"改成这样
不是数字类型么,把 (Z1WEK+p_numberEditor0) 两边的单引号去掉试试。
${if(len(p_numberEditor0)==0,"","and RGWEK <= CONVERT(int,Z1WEK) + '"+p_numberEditor0+"'")}
试一下
${if(len(p_numberEditor0)==0,"",if("SUBSTRING(Z1WEK, 5, 2)"=52,"and RGWEK <= CONVERT(int,SUBSTRING(Z1WEK,1,4)) + 1 + '"+p_numberEditor0+"'","and RGWEK <= CONVERT(int,Z1WEK) + '"+p_numberEditor0+"'"))}