Skip to content

Commit

Permalink
Fixed issue #14135: Evaluation of survey statistics generates a query…
Browse files Browse the repository at this point in the history
… error when using PostgreSQL DB server
  • Loading branch information
dominikvitt committed Jan 9, 2019
1 parent 1f04efc commit 745fa58
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -914,20 +914,20 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
//other databases (MySQL, Postgres)
else {
//standard deviation
$query = "SELECT STDDEV(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as stdev";
$query = "SELECT STDDEV(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(26,6))) as stdev";
}

//sum
$query .= ", SUM(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as sum";
$query .= ", SUM(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(26,6))) as sum";

//average
$query .= ", AVG(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as average";
$query .= ", AVG(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(26,6))) as average";

//min
$query .= ", MIN(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as minimum";
$query .= ", MIN(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(26,6))) as minimum";

//max
$query .= ", MAX(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as maximum";
$query .= ", MAX(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(26,6))) as maximum";
//Only select responses where there is an actual number response, ignore nulls and empties (if these are included, they are treated as zeroes, and distort the deviation/mean calculations)

//special treatment for MS SQL databases
Expand Down

0 comments on commit 745fa58

Please sign in to comment.