You need to sign in to do that
Don't have an account?
Aratz Guerra
need query in SOQL
Hello, I have this query:
SELECT b.Outstanding_Amount__c
FROM Billing__C b, Contract c
WHERE b.Contract_Number__C = c.ContractNumber
AND c.AccountId =: cuenta.Id
(cuenta.Id is the value that I pass)
But i need to do it in SOQL, could anybody help me pease?
SELECT b.Outstanding_Amount__c
FROM Billing__C b, Contract c
WHERE b.Contract_Number__C = c.ContractNumber
AND c.AccountId =: cuenta.Id
(cuenta.Id is the value that I pass)
But i need to do it in SOQL, could anybody help me pease?
This is not possible in one soql. You can try this bu using
List<Contract> contractLst = [SELECT Id, ContractNumber FROM Contract WHERE c.AccountId =: cuenta.Id];
List<String> contractNumbers = new List<String>();
for(Contract contract : contractLst) {
contractNumbers.add(contract.ContractNumber);
}
List<Billing__C> billingLst = [SELECT b.Outstanding_Amount__c FROM Billing__C b WHERE b.Contract_Number__C IN: contractNumbers];
All Answers
What I mean is that I want to rewrite the originsl query to SOQL.
I´ve tried something like this:
myList = [select Outstanding_Amount__c FROM Billing__C WHERE Contract_Number__C IN (select ContractNumber FROM Contract WHERE AccountId =: cuenta.Id)];
but it doesn´t work.... any clue?
This is not possible in one soql. You can try this bu using
List<Contract> contractLst = [SELECT Id, ContractNumber FROM Contract WHERE c.AccountId =: cuenta.Id];
List<String> contractNumbers = new List<String>();
for(Contract contract : contractLst) {
contractNumbers.add(contract.ContractNumber);
}
List<Billing__C> billingLst = [SELECT b.Outstanding_Amount__c FROM Billing__C b WHERE b.Contract_Number__C IN: contractNumbers];