php - How to perform MySQL 'SUM' but to '0' decimal places? -
i have mysql table containing account balances, stored floats, 2 decimal places, in varbinary
column type (because values aes_encrypted).
i realise it's not ideal storing values floats , in later tables no longer are, can't legacy table yet, need work is.
i'm trying compute sum of balances, able code below:
$s=$dbh->prepare(" select sum(aes_decrypt(a.acct_balance, '".dbkey."')) tbal accounts inner join coa c on a.acc_id = c.acc_id c.acc_type_id = ? , a.acc_type = 1 ");
however, reports display balances individually 0 decimal spaces , if add up, different result above query computed using values 2 decimal places, after converting result 0 decimal places.
i think need inform mysql temporarily convert each value 0 decimal spaces before adding running total, how that?
the values i'm displaying in report converted using:
$val = number_format($val, 0, '', ',');
it might simple this?
sum(round(aes_decrypt(a.acct_balance, '".dbkey."')))
that make sum of rounded values
Comments
Post a Comment