issue in decimal places
Posted: Fri May 19, 2006 1:35 am
Code: Select all
mysql_query("SELECT avg( vote ) as average, sum( vote ) as total, count( vote ) as total_v FROM story_vote where sid = $poetryid") or die(mysql_error());A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
mysql_query("SELECT avg( vote ) as average, sum( vote ) as total, count( vote ) as total_v FROM story_vote where sid = $poetryid") or die(mysql_error());Code: Select all
ROUND(x) and ROUND(x,y)
Returns the value of x rounded to the nearest integer. ROUND can also accept an additional argument y that will round x to y decimal places.
select ROUND(14.492);
+---------------+
| ROUND(14.492) |
+---------------+
| 14 |
+---------------+
1 row in set (0.00 sec)
select ROUND(4.5002);
+---------------+
| ROUND(4.5002) |
+---------------+
| 5 |
+---------------+
1 row in set (0.00 sec)
select ROUND(-12.773);
+----------------+
| ROUND(-12.773) |
+----------------+
| -13 |
+----------------+
1 row in set (0.00 sec)
select ROUND(7.235651, 3);
+--------------------+
| ROUND(7.235651, 3) |
+--------------------+
| 7.236 |
+--------------------+
1 row in set (0.00 sec)