Skip to content

Commit

Permalink
Fixed issue: Postgres has no DOUBLE database type
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed May 14, 2018
1 parent 5736e13 commit a0399bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -913,20 +913,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 DOUBLE)) as stdev";
$query = "SELECT STDDEV(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,6))) as stdev";
}

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

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

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

//max
$query .= ", MAX(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DOUBLE)*1) as maximum";
$query .= ", MAX(CAST(".Yii::app()->db->quoteColumnName($fieldname)." AS DECIMAL(10,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 a0399bf

Please sign in to comment.