is this code is correct??

Map<String, AggregateResult> monthAggMap = new Map<String, AggregateResult>();
List<Opportunity_Calendarize__c> updatedRecords = new List<Opportunity_Calendarize__c>();

for (AggregateResult monthAggQuarter : [
    SELECT Quarter_Name__c, OpportunityLineItemId__c,
           SUM(Adjusted_Sell_Out_Qty__c) Total_Adjusted_Sell_Out_Qty,
           SUM(Adjusted_Inventory_Actual__c) Total_Adjusted_Inventory_Actual,
           SUM(Actual_Sell_Out_Qty__c) Total_Actual_Sell_Out_Qty,
           SUM(Actual_Inventory_Qty__c) Total_Actual_Inventory_Qty,
           SUM(Inventory_Qty__c) Total_Inventory_Qty,
           SUM(Planned_Sell_In_Qty__c) Total_Planned_Sell_In_Qty,
           SUM(Planned_Sell_Out_Qty__c) Total_Planned_Sell_Out_Qty,
           SUM(Forecast_Qty__c) Total_Forecast_Qty,
           SUM(Sell_Out_Qty__c) Total_Sell_Out_Qty,
           SUM(FSF_Sell_In_Quantity__c) Total_FSFSellInQuantity,
           SUM(FSF_SellOut__c) Total_FSFSellOut,
           SUM(Upsides_Above_Allocation_Sell_In__c) Total_UpsidesAboveAllocationSellIn,
           SUM(Upsides_Above_Allocation_Sell_Out__c) Total_UpsidesAboveAllocationSellOut,
           SUM(Returns_Forecast__c) Total_ReturnsForecast,
           SUM(Sell_In_Actuals_Qty__c) Total_SellInActualsQty,
           SUM(POG_Actuals_Qty__c) Total_POGActualsQty,
           SUM(Export_Qty_Nbr__c) Total_ExportQtyNbr,
           SUM(Import_Qty_Nbr__c) Total_ImportQtyNbr,
           SUM(ISF_Sell_Out_Qty_In_Ha__c) Total_ISFSellOutQtyInHa,
           SUM(FSF_Sell_Out_Qty_In_Ha__c) Total_FSFSellOutQtyInHa,
           SUM(Planned_Sell_Out_Qty_Ha__c) Total_PlannedSellOutQtyHa,
           SUM(Forecast_Amt__c) Total_ForecastAmt,
           SUM(Sell_Out_Amt__c) Total_SellOutAmt,
           SUM(Upsides_Above_Allocation_Sell_In_Amt__c) Total_UpsidesAboveAllocationSellInAmt,
           SUM(Upsides_Above_Allocation_Sell_Out_Amt__c) Total_UpsidesAboveAllocationSellOutAmt,
           SUM(FSF_Sell_In_Amount__c) Total_FSFSellInAmount,
           SUM(FSF_SellOut_Amount__c) Total_FSFSellOutAmount,
           SUM(Planned_Sell_In_Amt__c) Total_PlannedSellInAmt,
           SUM(Planned_Sell_Out_Amt__c) Total_PlannedSellOutAmt,
           SUM(Returns_Forecast_Amt__c) Total_ReturnsForecastAmt,
           SUM(Returns_Actuals_Amt__c) Total_ReturnsActualsAmt,
           SUM(Inventory_Amt__c) Total_InventoryAmt,
           SUM(Adjusted_Sell_Out_Amt__c) Total_AdjustedSellOutAmt
    FROM Opportunity_Calendarize__c
    WHERE Line_Type__c = 'Monthly' AND OpportunityLineItemId__c IN :Ids
    GROUP BY Quarter_Name__c, OpportunityLineItemId__c]) {
    String key = String.valueOf(monthAggQuarter.get('OpportunityLineItemId__c')) + '_' + String.valueOf(monthAggQuarter.get('Quarter_Name__c'));
    monthAggMap.put(key, monthAggQuarter);
}

for (Opportunity_Calendarize__c quarter : [
    SELECT Id, Quarter_Name__c, OpportunityLineItemId__c,
           Adjusted_Sell_Out_Qty__c, Adjusted_Inventory_Actual__c,
           Actual_Sell_Out_Qty__c, Actual_Inventory_Qty__c,
           Inventory_Qty__c, Planned_Sell_In_Qty__c,
           Planned_Sell_Out_Qty__c, Forecast_Qty__c,
           Sell_Out_Qty__c, FSF_Sell_In_Quantity__c,
           FSF_SellOut__c, Upsides_Above_Allocation_Sell_In__c,
           Upsides_Above_Allocation_Sell_Out__c, Returns_Forecast__c,
           Sell_In_Actuals_Qty__c, POG_Actuals_Qty__c,
           Export_Qty_Nbr__c, Import_Qty_Nbr__c,
           ISF_Sell_Out_Qty_In_Ha__c, FSF_Sell_Out_Qty_In_Ha__c,
           Planned_Sell_Out_Qty_Ha__c, Forecast_Amt__c,
           Sell_Out_Amt__c, Upsides_Above_Allocation_Sell_In_Amt__c,
           Upsides_Above_Allocation_Sell_Out_Amt__c, FSF_Sell_In_Amount__c,
           FSF_SellOut_Amount__c, Planned_Sell_In_Amt__c,
           Planned_Sell_Out_Amt__c, Returns_Forecast_Amt__c,
           Returns_Actuals_Amt__c, Inventory_Amt__c,
           Adjusted_Sell_Out_Amt__c
    FROM Opportunity_Calendarize__c
    WHERE Line_Type__c = 'Quarterly' AND OpportunityLineItemId__c IN :Ids
    GROUP BY Id, Quarter_Name__c, OpportunityLineItemId__c]) {
    String key = String.valueOf(quarter.OpportunityLineItemId__c) + '_' + String.valueOf(quarter.Quarter_Name__c);
    if (monthAggMap.containsKey(key)) {
        AggregateResult monthagg = monthAggMap.get(key);
                    quarter.Adjusted_Sell_Out_Qty__c = (Decimal)monthagg.get('Total_Adjusted_Sell_Out_Qty');
                    quarter.Adjusted_Inventory_Actual__c = (Decimal)monthagg.get('Total_Adjusted_Inventory_Actual');
                    quarter.Actual_Sell_Out_Qty__c = (Decimal)monthagg.get('Total_Actual_Sell_Out_Qty');
                    quarter.Actual_Inventory_Qty__c = (Decimal)monthagg.get('Total_Actual_Inventory_Qty');
                    quarter.Inventory_Qty__c = (Decimal)monthagg.get('Total_Inventory_Qty');
                    quarter.Planned_Sell_In_Qty__c = (Decimal)monthagg.get('Total_Planned_Sell_In_Qty');
                    quarter.Planned_Sell_Out_Qty__c = (Decimal)monthagg.get('Total_Planned_Sell_Out_Qty');
                    quarter.Forecast_Qty__c = (Decimal)monthagg.get('Total_Forecast_Qty');
                    quarter.Sell_Out_Qty__c = (Decimal)monthagg.get('Total_Sell_Out_Qty');
                    quarter.FSF_Sell_In_Quantity__c = (Decimal)monthagg.get('Total_FSFSellInQuantity');
                    quarter.FSF_SellOut__c = (Decimal)monthagg.get('Total_FSFSellOut');
                    quarter.Upsides_Above_Allocation_Sell_In__c = (Decimal)monthagg.get('Total_UpsidesAboveAllocationSellIn');
                    quarter.Upsides_Above_Allocation_Sell_Out__c = (Decimal)monthagg.get('Total_UpsidesAboveAllocationSellOut');
                    quarter.Returns_Forecast__c = (Decimal)monthagg.get('Total_ReturnsForecast');
                    quarter.Sell_In_Actuals_Qty__c = (Decimal)monthagg.get('Total_SellInActualsQty');
                    quarter.POG_Actuals_Qty__c = (Decimal)monthagg.get('Total_POGActualsQty');
                    quarter.Export_Qty_Nbr__c = (Decimal)monthagg.get('Total_ExportQtyNbr');
                    quarter.Import_Qty_Nbr__c = (Decimal)monthagg.get('Total_ImportQtyNbr');
                    quarter.ISF_Sell_Out_Qty_In_Ha__c = (Decimal)monthagg.get('Total_ISFSellOutQtyInHa');
                    quarter.FSF_Sell_Out_Qty_In_Ha__c = (Decimal)monthagg.get('Total_FSFSellOutQtyInHa');
                    quarter.Planned_Sell_Out_Qty_Ha__c = (Decimal)monthagg.get('Total_PlannedSellOutQtyHa');
                    quarter.Forecast_Amt__c = (Decimal)monthagg.get('Total_ForecastAmt');
                    quarter.Sell_Out_Amt__c = (Decimal)monthagg.get('Total_SellOutAmt');
                    quarter.Upsides_Above_Allocation_Sell_In_Amt__c = (Decimal)monthagg.get('Total_UpsidesAboveAllocationSellInAmt');
                    quarter.Upsides_Above_Allocation_Sell_Out_Amt__c = (Decimal)monthagg.get('Total_UpsidesAboveAllocationSellOutAmt');
                    quarter.FSF_Sell_In_Amount__c = (Decimal)monthagg.get('Total_FSFSellInAmount');
                    quarter.FSF_SellOut_Amount__c = (Decimal)monthagg.get('Total_FSFSellOutAmount');
                    quarter.Planned_Sell_In_Amt__c = (Decimal)monthagg.get('Total_PlannedSellInAmt');
                    quarter.Planned_Sell_Out_Amt__c = (Decimal)monthagg.get('Total_PlannedSellOutAmt');
                    quarter.Returns_Forecast_Amt__c = (Decimal)monthagg.get('Total_ReturnsForecastAmt');
                    quarter.Returns_Actuals_Amt__c = (Decimal)monthagg.get('Total_ReturnsActualsAmt');
                    quarter.Inventory_Amt__c = (Decimal)monthagg.get('Total_InventoryAmt');
                    quarter.Adjusted_Sell_Out_Amt__c = (Decimal)monthagg.get('Total_AdjustedSellOutAmt');
                    
                    updatedRecords.add(quarter);
                }
            }

if (!updatedRecords.isEmpty()) {
    update updatedRecords;
}