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
bryansosa01bryansosa01 

Aggregate Functuions and Subquery

I want tu SUM the MAX values from an Object

 

I want to do something like this:

SELECT sum(max(Exposici_n__c)) FROM  Cartera_de_Credito__c WHERE Fecha_al__c = 2013-06-30  Group BY Banda_2__c  ORDER BY Max(Banda__c)

 

 

Please help.

Bryan Sosa.

IspitaIspita

Hi Bryan,

Where do you want this output?

If you want want this output it can be show using reports and summary fields formula (on reports)

Report route:-

Create summary report group by Banda_2__c

Then add a summary formula on report which brings within each grouping

As you create such a field you can have summation at all levels.

 

Hope this helps

bryansosa01bryansosa01

Thanks for your answer,

 

I want to save the SUM into a field of a record of another object that is not related. The report would not work.

 

Thanks for your help.

goabhigogoabhigo

Use a AggregateResult list and iterate it in a loop, use a variable to sum the MAX, then out of the for loop assign the total value from variable to the field.

Does this make sense? Let me know if you want me to give you code snippet (I would highly recommend you to do it yourself :) ).

bryansosa01bryansosa01

Thank you very much for your answer,

 

I really appreciate if you could provide a snippet of code.

 

Bryan Sosa.