function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ugsfdcugsfdc 

SOQL Issue

Dear Experts,
I want to fetch the second highest salary from object using SOQL and i was tried to use inner query it showing error.Could you suggest me how we can do it.



Regards,
ugsfdc.
 
Best Answer chosen by ugsfdc
JazzcatJazzcat
Assuming you have at least two items, can't you just do this?

List<Object> myList = [Select Id, Salary From Objects__c Order By Salary Desc];
System.debug(myList[1].Salary)
 

All Answers

JazzcatJazzcat
Assuming you have at least two items, can't you just do this?

List<Object> myList = [Select Id, Salary From Objects__c Order By Salary Desc];
System.debug(myList[1].Salary)
 
This was selected as the best answer
ugsfdcugsfdc
Thank you Jazzcat it is helped me.


Regards,
ugsfdc.