function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDCIronManSFDCIronMan 

SOQL Query for comparing Parent Cancelation_Date__C Opportunity with Child CloseDate Opportunity for Deletein

**SOQL Query for comparing Parent Opportunity Cancelation_Date__C with Child Opportunity CloseDate for Deleteing Child Opportunities where Parent Opportunity Cancelation_Date__c Is less then Child Opportunity CloseDate**

//Please Help solve this
for(Opportunity childOppty : oppsToInsert)
            {
                for(Opportunity parentOppty : ListOpp)
                {
                    if(parentOppty.Cancelation_Date__c != Null && childOppty.CloseDate > parentOppty.Cancelation_Date__c ||parentOppty.Service_End_Date__c != Null && childOppty.CloseDate > parentOppty.Service_End_Date__c)
                    {
                        childOppIds.add(childOppty.Id);
                        parentDate = parentOppty.Cancelation_Date__c;
                    }
                }
            }
            
            List<Opportunity> oppsToDelete = [Select Id, CloseDate, Parent_Opportunity__c From Opportunity Where Id IN : childOppIds];
            
            if(!oppsToDelete.isEmpty())
            {
                delete oppsToDelete;
            }
//

Thanks in Advance 
AbhinavAbhinav (Salesforce Developers) 
Not able to understand your query requirement. Could be please be more specific .