Skip to main content

LIMIT

Specify the maximum number of rows to return.

SELECT Id, Name
FROM Account
LIMIT 1000
public inherited sharing class AccountSelector {

public static SQOL query {
get {
return SQOL.of(Account.SObjectType)
.with(new List<SObjectField>{
Account.Id,
Account.Name
});
}
}
}

public with sharing class MyController {

public static List<Account> getAccountsWithLimit() {
return AccountSelector.query
.setLimit(1000)
.toList();
}
}