sub_totals

 
          sub_totals($group_by_column, $function, $affected_columns)  
This function adds subtotals to your report to get the sum, average, minimum, maximum, or count of any column(s) for each group of records. Additionally, at the end of the report, grand totals should be listed.
# This method is exclusive to the commercial edition and is not supported in the community edition .

# Note

To use this function your report should be grouped. Therefore, the

# Parameters

Parameter Description
$group_by_columnThe column by which the report is grouped. In the below code example, "Country" is the $group_by_column
$functionThe subtotal function. It should be one of the following functions: SRE_SUM, SRE_AVERGAE, SRE_COUNT, SRE_MAX, or SRE_MIN.
$affected_columnsAn array of the columns on which you want to apply the subtotals function.

# Returns

This method returns the calling object, so it can be chained with other methods in the ‘ReportOptions’ class

# Code Example

 
           use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;

require_once "sre_bootstrap.php";

$report = new ReportOptions(SRE_PUBLIC_REPORT);
$report->select_tables(array("items"))
        ->set_grouping(array("Country"))
        ->sub_totals("Country", SRE_COUNT, array("price"))
        ->select_all_fields();

$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
    echo "Report created successfully! Your report URL: $report_path  ";
}