16 Aug SOQL GROUP BY ROLLUP CLAUSE
It is used to add subtotals to get aggregates data in the Query Result. Both GROUP BY and GROUP BY ROLLUP Clause are similar but SOQL GROUP BY ROLLUP Clause returns multiple levels of subtotal rows. When using GROUP BY ROLLUP Clause in a statement we can add up to three fields in a comma-seperated list.
Select city__c, state__c, COUNT(Employee_name__c) counts from Employee__c GROUP BY ROLLUP (city__c,state__c)
From above SOQL statement Grouped the data according to state, city and also calculates the number.
SOQL FOR REFERENCE CLAUSE
This clause is used to find Date or Time values when a record has been referenced. The LastReferencedDate field is automativally updated for any retrived records.
When coming to FOR REFERENCE Clause, this is used to take Date and Time of the Record when a Record has been Referenced last while executing a SOQL Query.
Select city__c, state__c, LastReferencedDate from Employee__c for Reference.
When we execute the above SOQL Statement all the records will show the same date and time.
SOQL FOR VIEW CLAUSE
It is used to find the Date of the Record when it has been last viewed. Every record will have standard field called LastViewedDate. This field will be updated for every retrieved records.
Select city__c,state__c,LastViewedDate from Employee__c forView.
When the above statement is executed for first time it shows the last viewed date and when the SOQL statement is executed for second time all records will show the same date and time for lastvieweddate.
“Explore – Techila Global Services, A Salesforce development company”