round

description

Syntax

round(x), round(x, d) Rounds the argument x to d decimal places. d defaults to 0 if not specified. If d is negative, the left d digits of the decimal point are 0. If x or d is null, null is returned.

example

1. mysql> select round(2.4);
2. +------------+
3. | round(2.4) |
4. +------------+
5. |          2 |
6. +------------+
7. mysql> select round(2.5);
8. +------------+
9. | round(2.5) |
10. +------------+
11. |          3 |
12. +------------+
13. mysql> select round(-3.4);
14. +-------------+
15. | round(-3.4) |
16. +-------------+
17. |          -3 |
18. +-------------+
19. mysql> select round(-3.5);
20. +-------------+
21. | round(-3.5) |
22. +-------------+
23. |          -4 |
24. +-------------+
25. mysql> select round(1667.2725, 2);
26. +---------------------+
27. | round(1667.2725, 2) |
28. +---------------------+
29. |             1667.27 |
30. +---------------------+
31. mysql> select round(1667.2725, -2);
32. +----------------------+
33. | round(1667.2725, -2) |
34. +----------------------+
35. |                 1700 |
36. +----------------------+

keywords

1. ROUND