group by _date_

2003-11-04 Thread taraben . a
Hello, I have a table bill like when (date), how_much (float), what (varchar). Now I store some bills on it - how_much will get numbers with 2 digits after point. Then I want to know how much money I spent each month. SELECT SUM(how_much), YEAR(when), MONTH(when) FROM bill GROUP BY

Re: group by _date_

2003-11-04 Thread Roger Baklund
* [EMAIL PROTECTED] Hello, I have a table bill like when (date), how_much (float), what (varchar). Now I store some bills on it - how_much will get numbers with 2 digits after point. Why do you think that? Note that FLOAT is an approximate numeric type. The value you insert is stored in a

Re: group by _date_

2003-11-04 Thread taraben . a
Thanks, Roger Baklund wrote: * [EMAIL PROTECTED] Hello, I have a table bill like when (date), how_much (float), what (varchar). Now I store some bills on it - how_much will get numbers with 2 digits after point. Why do you think that? Note that FLOAT is an approximate numeric type. The value

Re: group by _date_

2003-11-04 Thread Roger Baklund
* [EMAIL PROTECTED] [...] Does this mean I can not trust float, decimal etc. for financial purposes? Yes you can, but you need to consider the precission of your calculations and comparisons. How much is 1 dollar divided by 3, if you can only use two digits for decimals? What do you do with the

Re: group by _date_

2003-11-04 Thread Roger Baklund
* [EMAIL PROTECTED] [...] Aha, now I have SUM(ROUND(how_much,2)), this works so far. You should swap these two function calls, the way you are doing it you are summing up the rounded values, instead you should round the sum of the values: ROUND(SUM(how_much),2) -- Roger -- MySQL General