I am exploring a dataset in Microsoft SQL Server Management, regarding sales. I want to obtain the day with the highest number of items sold for each year, therefore a table like this (the values in the rows are totally random):
| Year | Purchase Day | Max_Daily_Sales | 
|---|---|---|
| 2011 | 2011-11-12 | 48 | 
| 2012 | 2012-12-22 | 123 | 
I first tried to run this query:
WITH CTE_DailySales AS
( 
    SELECT DISTINCT 
        Purchase_Day, 
        Year, 
        SUM(Order_Quantity) OVER (PARTITION BY Purchase_Day, Year) AS Daily_Quantity_Sold
    FROM 
        [sql_cleaning].[dbo].[Sales$]
)
SELECT   
    Year, MAX(Daily_Quantity_Sold) AS Max_Daily_Sales
FROM 
    CTE_DailySales
GROUP BY  
    Year
ORDER BY  
    Year
It partially works since it gives me the highest quantity of items sold in a day for each year. However, I would also like to specify what day of the year it was.
If I try to write Purchase_Day in the Select statement, it returns the max for each day, not the single day with the highest number of items sold.
How could I resolve this problem?
I hope I've been clear enough and thanks you all for your help
 
     
     
    