SELECT Quarter, Month, ROUND(Sales,0)/1000 M_Sales, ROUND(SUM(Sales) OVER (PARTITION BY Quarter),0)/1000 AS Q_Sales, ROUND(SUM(Sales) OVER (PARTITION BY Year),0)/1000 AS Y_Sales FROM ( SELECT calendaryear Year, calendarquarter Quarter, monthnumberofyear Month, SUM(transactionprice*quantity) AS Sales, COUNT(DISTINCT customerkey) AS CustNum FROM factonlinesales fos INNER JOIN dimdate dd ON fos.orderdatekey= dd.datekey WHERE calendaryear = 2024 GROUP BY calendaryear, calendarquarter, monthnumberofyear ) ORDER BY 1 ;