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
Adil_SFDCAdil_SFDC 

Most Recent Records in the LIst

Hi All 

 

I have a SOQL Query which returns me following results of Product in  a LIST

Select Account__c,Order_Status__c, Case_Number__c, Product_Description__r.Is_Package__c, Product_Description__r.Name
From Order_History__c

 

1. Name : Branding    Last Modified: 06/28/13

2.  Name : AHL   Last Modified: 06/2/13

3. Name : CHAT    Last Modified: 06/28/13

4. Name : Branding    Last Modified: 06/29/13

5.Name: CHAT     Last Modified: 06/27/13

 


In the above list i have two similar product names i just want to get most recent modified Product Name. I want my list to look like 

 

 

1.  Name : AHL   Last Modified: 06/2/13

2. Name : CHAT    Last Modified: 06/28/13

3. Name : Branding    Last Modified: 06/29/13

 

 

hOW DO I MODIFY MY QUERY TO GET THE ABOVE RESULT

Avidev9Avidev9

You can use the order by clause

Select Account__c,Order_Status__c, Case_Number__c, Product_Description__r.Is_Package__c, Product_Description__r.Name
From Order_History__c Order By name ASC,LastModifiedDate DESC

Adil_SFDCAdil_SFDC

Yeah but it would just order the list in Descending order of Last Modified Date . 

 I just need most recent  of the 2 identical Products.  If there are 2 CHATs and 2 Brandings I just need one. 

Avidev9Avidev9
Probably a pure SOQL solution is not possible.
You have use apex to eliminate the duplicate records.