Skip to content

Commit

Permalink
Put the having clause after the group by clause to resolve this upstr…
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jul 29, 2010
1 parent b3c1b46 commit 941a350
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions system/libraries/Database_Builder.php
Expand Up @@ -1021,14 +1021,14 @@ protected function compile()
$sql .= "\n".'WHERE '.$this->compile_conditions($this->where);
}

if ( ! empty($this->having))
if ( ! empty($this->group_by))
{
$sql .= "\n".'HAVING '.$this->compile_conditions($this->having);
$sql .= "\n".'GROUP BY '.$this->compile_group_by();
}

if ( ! empty($this->group_by))
if ( ! empty($this->having))
{
$sql .= "\n".'GROUP BY '.$this->compile_group_by();
$sql .= "\n".'HAVING '.$this->compile_conditions($this->having);
}

if ( ! empty($this->order_by))
Expand Down

0 comments on commit 941a350

Please sign in to comment.