You need to sign in to do that
Don't have an account?
medemaza
How to not SOQL Distinct
public class LastOfferPrice { public ID OpportunityID{get; set;} List<OpportunityLineItem> Item; public List<OpportunityLineItem> getItem(){ if(Item==null){ Item = [Select Id,PricebookEntry.Product2.Name,ListPrice,UnitPrice,Opportunity.CloseDate,LastModifiedDate From OpportunityLineItem Where OpportunityId=:OpportunityID ORDER BY PricebookEntry.Product2.Name DESC]; } return Item; } List<OpportunityLineItem> LastOffer; public List<OpportunityLineItem> getLastOffer(){ for(OpportunityLineItem I:Item){ LastOffer = [Select Id,distinct (PricebookEntry.Product2.Name,ListPrice),UnitPrice,LastModifiedDate From OpportunityLineItem Where LastModifiedDate <= YESTERDAY and PricebookEntry.Product2.Name=:I.PricebookEntry.Product2.Name ORDER BY ID DESC ]; } return LastOffer; } }
Is error How to query not duplicate name of product
Hi,
As Bob and Sharma said, there is no Distinct in SOQL. You have to do that in your code manually. I have a code example for eleminate duplicates. I hope that will help you to do your job.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog
All Answers
Unfortunately there is no equivalent of distinct in SOQL. You'll have to pull process the results of the query and carry out your own duplicate detection I'm afraid.
No distinct available in SOQL, Do this
1)Get All the records
2)Use for loop to eliminate duplicate records from the list.
Hi,
As Bob and Sharma said, there is no Distinct in SOQL. You have to do that in your code manually. I have a code example for eleminate duplicates. I hope that will help you to do your job.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog
Using a Set instead of a List will make sure that duplicates are removed by default as Set do not allow duplicate entries. So, for processing, we can put list of strings into a Set, which will remove duplicates.