Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL] Problem z zaokrąglaniem i sumowaniem.
Forum PHP.pl > Forum > Bazy danych > MySQL
skowron-line
Witam mam coś takiego
  1. SELECT sum( srba.przychod ) , round( sum( srba.przychod ) ) ...

i wynik dostaje taki.
Kod
sum( srba.przychod ) => 218316.50
round( sum( srba.przychod )  ) => 218316

z czego może wynikać fakt zaokrąglenia w dół questionmark.gif

Pozdrawiam.
nospor
http://dev.mysql.com/doc/refman/5.0/en/mat...#function_round
moze chodzi o to:
Cytat
For exact-value numbers, ROUND() uses the “round half up” or “round toward nearest” rule: A value with a fractional part of .5 or greater is rounded up to the next integer if positive or down to the next integer if negative. (In other words, it is rounded away from zero.) A value with a fractional part less than .5 is rounded down to the next integer if positive or up to the next integer if negative.

For approximate-value numbers, the result depends on the C library. On many systems, this means that ROUND() uses the "round to nearest even" rule: A value with any fractional part is rounded to the nearest even integer.

The following example shows how rounding differs for exact and approximate values:
mysql> SELECT ROUND(2.5), ROUND(25E-1);
+------------+--------------+
| ROUND(2.5) | ROUND(25E-1) |
+------------+--------------+
| 3 | 2 |
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.