set @a ='20221215-20221221';
set @i=0;
set @j=0;
set @b=0;
select no into @b from(
SELECT *,(@i:=@i+1) as no FROM (
SELECT '20221110-20221116' AS A
UNION ALL
SELECT '20221117-20221123' AS A
UNION ALL
SELECT '20221124-20221130' AS A
UNION ALL
SELECT '20221201-20221207' AS A
UNION ALL
SELECT '20221208-20221214' AS A
UNION ALL
SELECT '20221215-20221221' AS A
UNION ALL
SELECT '20221222-20221228' AS A
UNION ALL
SELECT '20221229-20230104' AS A
UNION ALL
SELECT '20230105-20230111' AS A
UNION ALL
SELECT '20230112-20230118' AS A
)c
)b where b.a='20221215-20221221';
-- SELECT @A=XH FROM #B WHERE A=@B
select * from(
SELECT *,(@j:=@j+1) as no FROM (
SELECT '20221110-20221116' AS A
UNION ALL
SELECT '20221117-20221123' AS A
UNION ALL
SELECT '20221124-20221130' AS A
UNION ALL
SELECT '20221201-20221207' AS A
UNION ALL
SELECT '20221208-20221214' AS A
UNION ALL
SELECT '20221215-20221221' AS A
UNION ALL
SELECT '20221222-20221228' AS A
UNION ALL
SELECT '20221229-20230104' AS A
UNION ALL
SELECT '20230105-20230111' AS A
UNION ALL
SELECT '20230112-20230118' AS A
)A )c WHERE no BETWEEN @b-4 AND @b+3
参考