Welcome Guest, Not a member yet? Register   Sign In
CI or MySQL bug?
#1

[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
#2

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...ecord.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);
#3

[eluser]Einspruch[/eluser]
THANK YOU!
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB