Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
微软SQL——
我正在寻找更改我的数据
OrderDate Amt 2012-03-05 1 2012-03-06 6 2012-03-06 7 2012-03-07 8 2012-03-08 1 2012-03-08 1
我希望它列出一周的开始日期是什么,例如 2012-01-01(假设这是星期天)并将本周的所有金额分组到该日期..
这在 SQL 中怎么可能?
谢谢詹姆斯。
Select DateAdd(D,1-DatePart(Dw,OrderDate),OrderDate) OrderStartOfWeekDate, Sum(Amt) TotalAmt From Tbl Group by DateAdd(D,1-DatePart(Dw,OrderDate),OrderDate);