Answers for "add week ending date sql server"

SQL
0

add week ending date sql server

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))
Posted by: Guest on June-24-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language