我有一个SQL查询,我需要将周结束日期显示为星期一。我测试了以下代码,但在星期六,星期日,星期一等都收到了回复。请帮帮忙?
SELECT DATEADD(DD, 7-(DATEPART(DW, MIN([Date])))
, MIN([Date])) AS EndOfWeek, COUNT(*) AS TermsPerWeek
FROM Table
WHERE [Date] NOT LIKE 'null'
AND ([Date] LIKE '%2016%' OR [Date] LIKE '%2017%')
GROUP BY DATEPART(WEEK,[Date]);