with a as (select '1周' , 1 ,CASE WHEN 1>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '2周', 2,CASE WHEN 2>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '3周', 3,CASE WHEN 3>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '4周', 4,CASE WHEN 4>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '5周', 5,CASE WHEN 5>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '6周', 6,CASE WHEN 6>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '7周', 7,CASE WHEN 7>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '8周', 8,CASE WHEN 8>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '9周', 9,CASE WHEN 9>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '10周', 10,CASE WHEN 10>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '11周', 11,CASE WHEN 11>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '12周', 12,CASE WHEN 12>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '13周', 13,CASE WHEN 13>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '14周', 14,CASE WHEN 14>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '15周', 15,CASE WHEN 15>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '16周', 16,CASE WHEN 16>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '17周', 17,CASE WHEN 17>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '18周', 18,CASE WHEN 18>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '19周', 19,CASE WHEN 19>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '20周', 20,CASE WHEN 20>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '21周', 21,CASE WHEN 21>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '22周', 22,CASE WHEN 22>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '23周', 23,CASE WHEN 23>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '24周', 24,CASE WHEN 24>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '25周', 25,CASE WHEN 25>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '26周', 26,CASE WHEN 26>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '27周', 27,CASE WHEN 27>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '28周', 28,CASE WHEN 28>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '29周', 29,CASE WHEN 29>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '30周', 30,CASE WHEN 30>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '31周', 31,CASE WHEN 31>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '32周', 32,CASE WHEN 32>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '33周', 33,CASE WHEN 33>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '34周', 34,CASE WHEN 34>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '35周', 35,CASE WHEN 35>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '36周', 36,CASE WHEN 36>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '37周', 37,CASE WHEN 37>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '38周', 38,CASE WHEN 38>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '39周', 39,CASE WHEN 39>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '40周', 40,CASE WHEN 40>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '41周', 41,CASE WHEN 41>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '42周', 42,CASE WHEN 42>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '43周', 43,CASE WHEN 43>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '44周', 44,CASE WHEN 44>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '45周', 45,CASE WHEN 45>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '46周', 46,CASE WHEN 46>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '47周', 47,CASE WHEN 47>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '48周', 48,CASE WHEN 48>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '49周', 49,CASE WHEN 49>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '50周', 50,CASE WHEN 50>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '51周', 51,CASE WHEN 51>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '52周', 52,CASE WHEN 52>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1union allselect '53周', 53,CASE WHEN 53>datepart(WK, getdate()) THEN '未到' ELSE '已过' END AS 判断1)select * from a left join (SELECT COUNT( A.采购数量 ) AS 批次, SUM( A.采购数量 ) AS 总数,大区分,供应商, WEEK1, WEEK2FROM (SELECT 供应商,采购数量, CONVERT ( VARCHAR ( 10 ), datepart(WK, 答复日期) ) + N'周' AS WEEK1, datepart(WK, 答复日期) AS WEEK2,大区分,答复日期 FROM . WHERE CONVERT ( VARCHAR ( 10 ), 答复日期, 120 ) > '2021-12-31' AND CONVERT ( VARCHAR ( 10 ), 答复日期, 120 ) < '2023-01-01' ) A -- WHERE-- 供应商 = '${供应商}'${if(大区分="全部","",if(大区分="其他","and 大区分 NOT IN ('AA' ,'AB', 'AC' ,'AD','AE')","and 大区分='"+大区分+"'")) } GROUP BY 大区分,供应商, WEEK1, WEEK2) T ON A.WEEK_=T.WEEK1 ORDER BY NUM_ ASC 你看这个日这么多365个我一个一个写吗