Page Two of the Directory
Intermediate SolvedA custom directory component shows three contacts per page, sorted by last name. The user has just clicked to page two.
Return the LastName of the contacts on page two, with three contacts per page, sorted by LastName from A to Z.
Sample data
Contact 7 records
| LastName |
|---|
| Fernandes |
| Ahuja |
| Hegde |
| Chopra |
| Desai |
| Bose |
| Gill |
Expected result on the sample
| LastName |
|---|
| Desai |
| Fernandes |
| Gill |
Row order matters for this problem. Only the columns above are compared; extra columns in your SELECT are fine.
Hints
- Page two skips the first page:
OFFSET 3. - Paging without ORDER BY returns rows in no guaranteed order.
What this tests
LIMIT with OFFSET is the simplest way to page through results, and paging only works with a stable ORDER BY. OFFSET tops out at 2,000 rows and gets slower as it grows, which is why large lists move to keyset paging or Apex cursors. Interviewers often follow up on exactly that limit.
Datasets
Solved on this device only. Sign in with Google to keep your progress across devices.
Run on sample executes your query against the sample data shown on the left and displays the rows it returns. Submit checks it against the sample plus 2 hidden datasets, comparing your rows with the expected rows on each. Queries run in a real Salesforce org; the data is inserted for your run and rolled back afterwards.