📜  添加星期结束日期 sql server - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:08.254000             🧑  作者: Mango

代码示例1
SELECT  
    DATEADD(DAY, 7 - DATEPART(WEEKDAY, orderDate), CAST(orderDate AS DATE)) AS ordersPerWeek, 
    sum(orderAmount) AS orderSumForGrouping, 
    count(1) AS numberOfOrdersWithinGrouping
FROM    @table o
GROUP   BY DATEADD(DAY, 7 - DATEPART(WEEKDAY, orderDate), CAST(orderDate AS DATE))