Search code examples
sqlsalesforcesoql

Divide results of two SOQL queries


I have two SOQL queries that access data from Salesforce that I want to divide. On their own each query works, and I want to divide their results by one another, but I am unsure how.

This is what I have tried:

select
(select count(success__c) from Account where success__c='yes'
and success__c>'30' and success__c<'37')
/
(select count(success__c) from Account where success__c='no')
As result

My SQL and SOQL experience is limited, so any advice is much appreciated.


Solution

  • You can't do this directly in SOQL, you'll need to run both queries and do the division in whatever code is making these queries.