*
*/
public static function getGroupByFromOrderBy(&$groupBy, $orderBys) {
- if (!CRM_Utils_SQL::disableFullGroupByMode()) {
+ if (CRM_Utils_SQL::disableFullGroupByMode()) {
foreach ($orderBys as $orderBy) {
$orderBy = str_replace(array(' DESC', ' ASC'), '', $orderBy); // remove sort syntax from ORDER BY clauses if present
// if ORDER BY column is not present in GROUP BY then append it to end
- if (!strstr($groupBy, $orderBy)) {
+ if (preg_match('/(MAX|MIN)\(/i', trim($orderBy)) !== 1 && !strstr($groupBy, $orderBy)) {
$groupBy .= ", {$orderBy}";
}
}
'order_bys' => array(
'start_date' => array(
'title' => ts('Start Date'),
+ 'dbAlias' => 'MIN(mailing_job_civireport.start_date)',
),
'end_date' => array(
'title' => ts('End Date'),
'default_weight' => '1',
'default_order' => 'DESC',
+ 'dbAlias' => 'MAX(mailing_job_civireport.end_date)',
),
),
'grouping' => 'mailing-fields',