function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public class TestApex{ public static void groupBy(){ List<Account> accoundList = new List<Account>([SELECT Id, Name FROM Account LIMIT 50000]); Map<DateTime, List<Account>> createdDate_vs_OppList = new Map<DateTime, List<Account>>(); for(Account acc :accoundList){ // if key does not contains if(!createdDate_vs_OppList.containsKey(acc.createdDate)){ List<Account> accList = new List<Account>(); accList.add(acc); createdDate_vs_OppList.put(acc.CreatedDate,accList ); } // key already contains else{ List<Account> accList = new List<Account>(); accList = createdDate_vs_OppList.get(acc.CreatedDate); accList.add(acc); createdDate_vs_OppList.put(acc.CreatedDate,accList ); } } //Display Map for(DateTime dt : createdDate_vs_OppList.keySet()){ List<Account> accList = createdDate_vs_OppList.get(dt); System.debug('Account Created Date'+dt); System.debug('Account List'+accList); } } }
You can do this by using map.Kindly Find the solution. If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.