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
Charlone Gianan 1Charlone Gianan 1 

How to sort Contact record descending based on the Proficiency and ascending based on the Skill type.

Hi Guys!

Can someone assist me on how can I get the contact record sorted (Descending -> Proficiency) and (Ascending -> Skill Type) based on my query below. 

Employee Skills, Training and Certifications has a lookup relationship with Contact (Employee).

SELECT Name, Email
, (SELECT Skill_ID__r.Name, Proficiency__c, Year_of_Experience__c, Skill_Type__c FROM Employee_Skills__r)
, (SELECT Training_ID__r.Name FROM Employee_Training__r)
, (SELECT Certification_ID_r.Name FROM Employee_Certifications__r)
FROM Contact

Thank you! 
AnjunaAnjuna
SELECT Name, Email
, (SELECT Skill_ID__r.Name, Proficiency__c, Year_of_Experience__c, Skill_Type__c FROM Employee_Skills__r)
, (SELECT Training_ID__r.Name FROM Employee_Training__r)
, (SELECT Certification_ID_r.Name FROM Employee_Certifications__r)
FROM Contact ORDER BY Proficiency DESC, SkillType ASC
Lokesh KumarLokesh Kumar
HI Charlone,

Try the below SOQL Query.
SELECT Name, Email
, (SELECT Skill_ID__r.Name, Proficiency__c, Year_of_Experience__c, Skill_Type__c FROM Employee_Skills__r)
, (SELECT Training_ID__r.Name FROM Employee_Training__r)
, (SELECT Certification_ID_r.Name FROM Employee_Certifications__r)
FROM Contact ORDER BY Proficiency__c DESC, Skill_Type__c  ASC

Thanks !
sfdc loginsfdc login
Use this in Soql (from Contact Where Proficiency__c != null ORDER BY Proficiency__c DESC, Skill_Type__c != null ORDER BY  Skill_Type__c  ASC )