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
Mack DsozaMack Dsoza 

Explain me this condition below

        List<AggregateResult> aggQueryResult = [
                                                    SELECT Sum(Death_Benefit_Rs__c)deathBenefitSum,
                                                           Sum(Sum_Assured_Rs__c)sumAssured,recordType.Name RTName,
                                                            Entity__r.Name Entity
                                                    FROM
                                                            Insurance__c
                                                    WHERE                                                           
                                                            Flag__c=:'Data Entry'       
                                                    GROUP by
                                                            recordType.Name, Entity__r.Name
                                                ];        
  

Please explain me what it means, bcoz i am quite confuse that i have never putted my condition like this =: 'value'

tell me wht it this ?

Shashikant SharmaShashikant Sharma

It is a aggeregate function that you are querying.

 

Now best practice is that we only use colon sign ':' when it is followed by a variable, but it is not that if you will use a 'value' and it won't work, but it is not true vise versa, means that if you wont use colon while you provide a varible next to = then it will say unexpected token: 'your variable name'

 

Final conclusion :

1) If a particular value : you can use ':' or do it without it, best practice is do not use it in this case

2)If you use a variable : You must have to use colon ':' , other wise compile error will come.