Rank practice Accounts
ORDER BY sets the result order and LIMIT caps the row count.
Your task
Sort this run's four Accounts by Name from Z to A, and keep only the top two.
String tag = 'AS-Q303-' + UserInfo.getUserId() + '-' +
String.valueOf(Datetime.now().getTime());
String tagPrefix = tag + '%';
List<Account> seeded = new List<Account>{
new Account(Name = tag + '-A'),
new Account(Name = tag + '-B'),
new Account(Name = tag + '-C'),
new Account(Name = tag + '-D')
};
insert seeded;
List<Account> topRows = new List<Account>();
System.debug('Top count: ' + topRows.size());
System.debug('Top first: false');
System.debug('Top second: false');
System.debug('Top B left out: false');Requirements
Top count: 2should be built from the query resultORDER BY Name DESCshould be presentLIMIT 2should be presentTop count: 2should be printedTop first: trueshould be printedTop second: trueshould be printedTop B left out: trueshould be printed