!empty($this->_params['group_bys_freq'][$fieldName])
) {
- $append = "YEAR({$field['dbAlias']}),";
+ $append = "YEAR({$field['dbAlias']})";
if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]),
array('year')
)) {
$append = '';
}
- $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
+ $this->_groupBy[] = $append;
+ $this->_groupBy[] = "{$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
$append = TRUE;
}
else {
}
$this->_rollup = ' WITH ROLLUP';
- $this->appendSelect($this->_selectClauses, $this->_groupBy);
- $this->_groupBy = 'GROUP BY ' . implode(', ', $this->_groupBy) .
+ $this->appendSelect($this->_selectClauses, array_filter($this->_groupBy));
+ $this->_groupBy = 'GROUP BY ' . implode(', ', array_filter($this->_groupBy)) .
" {$this->_rollup} ";
}
else {