Collections:
TRUNCATE() - Truncating to Decimal Place
How to truncate a value to a given decimal place using the TRUNCATE() function?
✍: FYIcenter.com
TRUNCATE(X, D) is a MySQL built-in function that
truncates X to decimal place of D.
For example:
SELECT TRUNCATE(-1.58, 0), TRUNCATE(23.298, 1), TRUNCATE(23.298, -1); -- +--------------------+---------------------+----------------------+ -- | TRUNCATE(-1.58, 0) | TRUNCATE(23.298, 1) | TRUNCATE(23.298, -1) | -- +--------------------+---------------------+----------------------+ -- | -1 | 23.2 | 20 | -- +--------------------+---------------------+----------------------+
Reference information of the TRUNCATE() function:
TRUNCATE(X, D): val Returns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become zero. Arguments, return value and availability: X: Required. The value to be truncated. D: Optional. Default is 0. The decimal place to truncate to. val: Return value. The truncated value. Available since MySQL 4.0.
Related MySQL functions:
⇒ MySQL Functions on Date and Time
⇐ TAN() - Tangent Trigonometric Value
2023-11-14, 414🔥, 0💬
Popular Posts:
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
How To Look at the Current SQL*Plus System Settings in Oracle? If you want to see the current values...
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Convert Numeric Expression Data Types using the CONVERT() Function in SQL Server Transact-SQL...