CodeIgniter Forums
CI or MySQL bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI or MySQL bug? (/showthread.php?tid=41458)



CI or MySQL bug? - El Forum - 05-08-2011

[eluser]Einspruch[/eluser]
This code in my model works:
Code:
SUM(Billing.gross_amt) AS gross_revenue

but when I try to round the result to just two decimals using
Code:
ROUND(SUM(Billing.gross_amt),2) AS gross_revenue

I get this error:
Quote:Unknown column '2' in 'field list'

Any ideas as to what I am doing incorrectly? Is this a MySQL syntax issue or a CI issue?

Thanks!

Robert


CI or MySQL bug? - El Forum - 05-09-2011

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-guide/database/active_record.html

Quote:$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

Code:
$this->db->select('ROUND(SUM(Billing.gross_amt),2) AS gross_revenue', FALSE);



CI or MySQL bug? - El Forum - 05-09-2011

[eluser]Einspruch[/eluser]
THANK YOU!


CI or MySQL bug? - El Forum - 05-12-2011

[eluser]tenantfile[/eluser]
I don't know it will done work or not but round and sum are the aggregate functions.