ApexSensei

Drills SOQL queries

Filter Account names

WHERE keeps rows that meet a condition.

Your task

Build a LIKE pattern and return only this run's Accounts whose names start with North.

String tag = 'AS-Q302-' + UserInfo.getUserId() + '-' +
    String.valueOf(Datetime.now().getTime());
List<Account> seeded = new List<Account>{
    new Account(Name = tag + '-Northwind'),
    new Account(Name = tag + '-Northstar'),
    new Account(Name = tag + '-northbay'),
    new Account(Name = tag + '-Southwind'),
    new Account(Name = tag + '-FarNorth')
};
insert seeded;

List<Account> matches = new List<Account>();
System.debug('Filter count: ' + matches.size());
System.debug('Filter lowercase included: false');
System.debug('Filter exclusions: false');

Requirements

  1. Filter count: 3 should be built from the query result
  2. Name LIKE :northPattern should be present
  3. Filter count: 3 should be printed
  4. Filter lowercase included: true should be printed
  5. Filter exclusions: true should be printed

Sign in to open this drill