-1

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.

Alex Kuhar
  • 11
  • 4
  • I doubt the top one works, as you seem to be expecting `'yes'` to be between `'30'` and `'37'` (depending on the backing text encoding, one of those will be true, but not both). That, and you're searching for a range of values on the same column you want exactly _one_ value. It seems likely you have one or more typos in this query. – Clockwork-Muse Jun 10 '14 at 10:36

1 Answers1

0

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.

superfell
  • 18,780
  • 4
  • 59
  • 81