TRUNCATE
PostgreSQL equivalent:
Returns a number truncated to the specified number of decimal places without rounding.
MySQL 8.4
TRUNCATE(num, decimals)- num
- Number to truncateDECIMAL
- decimals
- Number of decimal places to keep, can be negativeINT
Return value
A number of the same type as num
Examples
Without the fractional part
MySQL 8.4
SELECT TRUNCATE(27.89, 0);To tenths
MySQL 8.4
SELECT TRUNCATE(27.89, 1);To tens
MySQL 8.4
SELECT TRUNCATE(27.89, -1);Details
Extra digits are dropped, also for negative numbers: TRUNCATE(-1.999, 1) returns -1.9.
With a negative decimals, digits to the left of the decimal point become zero: TRUNCATE(122, -2) returns 100. Unlike ROUND, the second argument is required.