Fixing issue 465: select_max is adding prefix to table aliases when is not necessary
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 7162e2a..8351823 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -196,7 +196,7 @@
 			$alias = $this->_create_alias_from_table(trim($select));
 		}
 
-		$sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
+		$sql = $this->_protect_identifiers($type.'('.trim($select).')').' AS '.$this->_protect_identifiers(trim($alias));
 
 		$this->ar_select[] = $sql;