**Note:** The result of this function is meant for use in the $additionalSelects parameter
in one of the query... methods (for example {@link queryVisitsByDimension()}).
**Example**
summarize one column
$visitTotalActionsRanges = array(
array(1, 1),
array(2, 10),
array(10)
);
$selects = LogAggregator::getSelectsFromRangedColumn('visit_total_actions', $visitTotalActionsRanges, 'log_visit', 'vta');
summarize another column in the same request
$visitCountVisitsRanges = array(
array(1, 1),
array(2, 20),
array(20)
);
$selects = array_merge(
$selects,
LogAggregator::getSelectsFromRangedColumn('visitor_count_visits', $visitCountVisitsRanges, 'log_visit', 'vcv')
);
perform the query
$logAggregator = // get the LogAggregator somehow
$query = $logAggregator->queryVisitsByDimension($dimensions = array(), $where = false, $selects);
$tableSummary = $query->fetch();
$numberOfVisitsWithOneAction = $tableSummary['vta0'];
$numberOfVisitsBetweenTwoAnd10 = $tableSummary['vta1'];
$numberOfVisitsWithVisitCountOfOne = $tableSummary['vcv0'];
public static getSelectsFromRangedColumn ( string $column, array $ranges, string $table, string $selectColumnPrefix, boolean $restrictToReturningVisitors = false ) : array | ||
$column | string | The name of a column in `$table` that will be summarized. |
$ranges | array | The array of ranges over which the data in the table will be summarized. For example, ``` array( array(1, 1), array(2, 2), array(3, 8), array(8) // everything over 8 ) ``` |
$table | string | The unprefixed name of the table whose rows will be summarized. |
$selectColumnPrefix | string | The prefix to prepend to each SELECT expression. This prefix is used to differentiate different sets of range summarization SELECTs. You can supply different values to this argument to summarize several columns in one query (see above for an example). |
$restrictToReturningVisitors | boolean | Whether to only summarize rows that belong to visits of returning visitors or not. If this argument is true, then the SELECT expressions returned can only be used with the {@link queryVisitsByDimension()} method. |
리턴 | array | An array of SQL SELECT expressions, for example, ``` array( 'sum(case when log_visit.visit_total_actions between 0 and 2 then 1 else 0 end) as vta0', 'sum(case when log_visit.visit_total_actions > 2 then 1 else 0 end) as vta1' ) ``` |