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
rosscorossco 

Accessing Single Aggregate Result

Hi All

 

I am trying to access a single aggregate result as in the follows (this is not meant to be  a group of results!)

 

decimal totaldebitorder = [select sum(amount__c) tot from Debit_Order_Transaction__c where Credit_agreement_No__c=:ca.id ].tot;

 

I am getting Invalid field tot for SObject AggregateResult error.

 

Please help?

 

thanks in advance

Ross

 

RonakPatel.ceRonakPatel.ce

hi,

 

Just use This Query

Decimal.valueof(String.valueof(

 

decimal totaldebitorder =Decimal.valueof(String.valueof( [select sum(amount__c) tot from Debit_Order_Transaction__c where Credit_agreement_No__c=:ca.id ][0].get('tot')));

 

If this is a answer then put this post as a solution..

Alok_NagarroAlok_Nagarro

Hi,

 

Try this :

 

decimal totaldebitorder = (Decimal) [select sum(amount__c) tot from Debit_Order_Transaction__c where Credit_agreement_No__c=:ca.id ][0].get('tot');

 

 

Navatar_DbSupNavatar_DbSup

Hi,


Try the below code as reference:


decimal totaldebitorder = (Decimal) [select sum(amount__c) tot from Debit_Order_Transaction__c][0].get('tot');
system.debug('@@@@@@@@@@@@@@@@' + totaldebitorder);


For more details please go through the link below:
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_agg_fns.htm

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Starz26Starz26

Hi,

 

Try the below code as a reference...

 

 

 

AHHHH Nevermind :)