You can use the format() function:

select t.custcode, format(sum(t.cost),2) as "Sub-Total"
from customer c, transaction t
where c.custcode = t.custcode
group by t.custcode

Marc.

-----Message d'origine-----
De : sam wun [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 24 décembre 2004 11:23
À : mysql@lists.mysql.com
Objet : Sum on Float type 


Hi,

I created a Transaction table with a field Cost which is a Float type 
with only 2 precision eg. 123.01.
When I use the following sql statement to make a sum of this field, it 
returned a Float number with more than 2 precision numbers  eg. 456.92384933

select t.custcode, sum(t.cost) as "Sub-Total"
from customer c, transaction t
where c.custcode = t.custcode
group by t.custcode

I don't know why the Sum function returns more than 2 precision number.
If I should not use Float type for the Cost field, what type should I use?

Thanks
Sam


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to