Development questions

Write a SOQL query to find the Nth Highest Salary on an Employee__c object.

Use ORDER BY ... DESC LIMIT 1 OFFSET N-1. For the 3rd highest salary:

soql
SELECT Id, Name, Salary__c FROM Employee__c
WHERE Salary__c != null
ORDER BY Salary__c DESC
LIMIT 1 OFFSET 2

In Apex, use a variable: LIMIT 1 OFFSET :n where n = N - 1. OFFSET max is 2,000. For distinct salaries, first group by Salary__c (aggregate) then apply the offset.

soqlscenariooffset