0
votes

i need to write The amount of orders for each month of the year and also the amount accumulated each year. Show a row highlighting the Year in Review

so fare i write thse : SELECT DISTINCT YEAR(OrderDate) AS OrderYear, MONTH(OrderDate) AS OrderMonth, SUM(subtotal) OVER(PARTITION BY YEAR(OrderDate),MONTH(OrderDate) ORDER BY YEAR(OrderDate),MONTH(OrderDate)) AS "sum_price", SUM(subtotal) OVER(PARTITION BY YEAR(OrderDate) ORDER BY MONTH(OrderDate)) AS "money"
FROM Sales.SalesOrderHeader ORDER BY YEAR(OrderDate), MONTH(OrderDate)

i need that every group we will see: year - 'grandtotal' - null - subtotal