SOQL GROUP BY ROLLUP CLAUSE | Techila
1059
single,single-post,postid-1059,single-format-standard,ajax_updown_fade,page_not_loaded,,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-9.4.2,bridge,wpb-js-composer js-comp-ver-4.12,vc_responsive
 

SOQL GROUP BY ROLLUP CLAUSE

SOQL GROUP BY ROLLUP CLAUSE

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)

 

SOQL statement Grouped

 

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.

 

 

Courtesy: http://www.crmsalesforcetraining.com/soql-group-by-rollup-clause/

“Explore – Techila Global Services, A Salesforce development company”

Author: techila

No Comments

Post A Comment