function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kkanthakkantha 

SOQL with maths

 Hi all,

 

Does anyone know how to write a SOQL which has a separate maths formula for individual fields?  I'm trying to get average values for several different fields in the same query, but I don't want to include any zero value records in the calculation.  Something like this:

 

Select AVG(Field1) only where Field1>0, AVG(Field2) only where Field2>0, AVG(Field3)only where Field3>0, AVG(Field4) only where Field4>0  etc etc

 

I thought of getting the zeros to read null by using a formula in the field construction itself, but the trouble with that is that my Google Charts don't work when even one of the summary fields are null.  I'm trying to query the database to do some google charts, but trying to incorporate calculations into the coding is a little bit beyond me.

 

Hope someone can help.