The ROUND() function rounds a number to a specified number of decimal places.
Note: See also the FLOOR(), CEIL(), CEILING(), and TRUNCATE() functions.
ROUND(
number,
decimals)
Parameter | Description |
---|---|
number | Required. The number to be rounded |
decimals | Optional. The number of decimal places to round number to. If omitted, it returns the integer (no decimals) |
Works in: | From MySQL 4.0 |
---|
Round the Price column (to 1 decimal) in the "Products" table:
SELECT ProductName, Price, ROUND(Price, 1) AS RoundedPrice
FROM Products;
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!