下面sql 是where下的,想实现 where STWEK = Z1WEK + 2STWEK,Z1WEK都是 202249这种格式的数据,表示2022年第49周因为怕Z1WEK + 2周数会大于一年的周数,涉及到年会加1,所以改成下面这这样,但是好像有问题,Z1WEK写死成数据202249就好用,但是不写死就查不到数据,有大佬知道怎么回事吗where STWEK = (select TOP 1case when SUBSTRING(CONVERT(char(10),CONVERT(int,Z1WEK) + 2), 5, 2) <= DATEPART(wk,CONCAT(left(Z1WEK,4),'-12','-31')) then CONVERT(int,Z1WEK) + 2when SUBSTRING(CONVERT(char(10),CONVERT(int,Z1WEK) + 2), 5, 2)-DATEPART(wk,CONCAT(left(Z1WEK,4),'-12','-31')) < 10 then CONVERT(char(4),CONVERT(int,SUBSTRING(Z1WEK,1,4)) + 1) + '0' +CONVERT(char(2),(SUBSTRING(CONVERT(char(10),CONVERT(int,Z1WEK) + 2), 5, 2)-DATEPART(wk,CONCAT(left(Z1WEK,4),'-12','-31'))))when SUBSTRING(CONVERT(char(10),CONVERT(int,Z1WEK) + 2), 5, 2)-DATEPART(wk,CONCAT(left(Z1WEK,4),'-12','-31')) > 9 then CONVERT(char(4),CONVERT(int,SUBSTRING(Z1WEK,1,4)) + 1)+CONVERT(char(2),SUBSTRING(CONVERT(char(10),CONVERT(int,Z1WEK) + 2), 5, 2)-DATEPART(wk,CONCAT(left(Z1WEK,4),'-12','-31')))endfrom dbo.ZNMS_JIT_H1_H)方式二: