PostgreSQL trim_scale() Function
The PostgreSQL trim_scale()
function removes trailing zeroes from the fractional part of a given number and returns the result.
trim_scale()
Syntax
This is the syntax of the PostgreSQL trim_scale()
function:
trim_scale(numeric_value) -> numeric
Parameters
numeric_value
-
Required. a number.
Return value
The PostgreSQL trim_scale(numeric_value)
function returns the given number with the trailing zeroes removed.
The trim_scale()
function will return NULL
if the argument is NULL
.
PostgreSQL will give an error if you supply a parameter that is not a numeric type.
trim_scale()
Examples
Here are a few examples of the trim_scale()
function:
SELECT
trim_scale(1.23000) AS "trim_scale(1.23000)",
trim_scale(1.23) AS "trim_scale(1.23)",
trim_scale(123) AS "trim_scale(123)";
trim_scale(1.23000) | trim_scale(1.23) | trim_scale(123)
---------------------+------------------+-----------------
1.23 | 1.23 | 123