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
kishore cmxkishore cmx 

write an soql to fetch all the opportunities where more than one record exit with same name and name contains "ABC"

SarfarajSarfaraj
List<String> names = new List<String>();
List<AggregateResult> ag = [Select Name From Opportunity Where Name like '%ABC%' group by name having count(Id) > 1];
for(AggregateResult a : ag)
    names.add((String)a.get('Name'));
List<Opportunity> opportunities = [Select Id From Opportunity Where Name in :names];