我已经在Microsoft sql server上查看了一周的结果,这是sql代码
SELECT TOP (100) PERCENT CONVERT(varchar, DATEPART(ww, D_Date), 101) AS ReportingWeek, Proj_name, SUM(Expr1) AS total
FROM dbo.View_Test_Two
GROUP BY CONVERT(varchar, DATEPART(ww, D_Date), 101), Proj_name
ORDER BY ReportingWeek
每件事情都没关系,但我的问题是周名称
现在我需要代替27,28,29,31,比如第1周,第2周,第3周......等等
.. 提前谢谢。
答案 0 :(得分:0)
这样做你想要的吗?
SELECT 'week ' + CONVERT(varchar(255), DATEPART(ww, D_Date) - 26) AS ReportingWeek,
Proj_name, SUM(Expr1) AS total
FROM dbo.View_Test_Two
GROUP BY DATEPART(ww, D_Date), Proj_name
ORDER BY min(D_Date);