You need to sign in to do that
Don't have an account?
Kevin Garcia 12
distinct values soql
Hello, I am trying to perform a SOQL query in Salesforce.
currently, when I search this query:
select Id, Account.Id, Account.WBCNumber__c from Opportunity
WHERE FiscalQuarter__c = 'Q2 2020'
and
AccountBoxoutNumber__c IN ('1-1206799572','1-1206525485','1-1206525485')
I only receive two values because the last two AccountBoxoutNumber values are repeating in the query. is there a way to make SOQL provide me with unique values even when there are repetitions in the Query?
currently, when I search this query:
select Id, Account.Id, Account.WBCNumber__c from Opportunity
WHERE FiscalQuarter__c = 'Q2 2020'
and
AccountBoxoutNumber__c IN ('1-1206799572','1-1206525485','1-1206525485')
I only receive two values because the last two AccountBoxoutNumber values are repeating in the query. is there a way to make SOQL provide me with unique values even when there are repetitions in the Query?
Little confuse about you saying receive only two values.
What distinct value you are looking for? Are you looking Distinct Values for Account.WBCNumber__c? Here is normally the way you get distinct value
Not sure if this help but may provide you some idea.
The query contains 3 numbers referring to 3 accounts. The last two are the same numbers referring to the same account.
When i run the query, SOQL only returns two values not 3.
I would like the query to return 3 values, even if the account numbers are the same.
The incorrect result is what I receive in the query. The Correct result below is what I am trying to achieve from my query.
Incorrect result:
"_" "Id" "Account" "Account.Id" "Account.WBCNumber__c"
"[Opportunity]" "0063g00000Bld6nAAB" "[Account]" "0013g00000YpFHLAA3" "1-1206525485"
"[Opportunity]" "0063g00000BlfTtAAJ" "[Account]" "0013g00000YpFpgAAF" "1-1206799572"
Correct result:
"_" "Id" "Account" "Account.Id" "Account.WBCNumber__c"
"[Opportunity]" "0063g00000Bld6nAAB" "[Account]" "0013g00000YpFHLAA3" "1-1206525485"
"[Opportunity]" "0063g00000BlfTtAAJ" "[Account]" "0013g00000YpFpgAAF" "1-1206799572"
"[Opportunity]" "0063g00000BlfTtAAJ" "[Account]" "0013g00000YpFpgAAF" "1-1206799572"
You by yourself saying the last two basically are the same AccountNumber, it doesn't matter how many time you put the same number it will only give you the amount of record it has.
How many Opportunities you have for those accounts in the system?
I saw your examples. It is a very strange requirements and trying to see the perpective you are trying to achieve with this.
however, i have a lot of orders that I am re-parenting to a new account and I need to query the opportunity id, account id, and account number because there are many orders from different customers that need to be re-parented.
it is working fine at my end.
"The query has to start with 'FIND' or 'SELECT'."
If you are running in Developer Console make sure you highlight the code and then run Execute Highlighted
Were you able to execute the code successfully?
You can do export via workbench https://workbench.developerforce.com/query.php easily, just run the SOQL as shown in the attachment
Im very sorry im trying to follow your instruction but I received another error pictures in the screenshot.