> This page location: Math Functions > TRIM_SCALE
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL TRIM_SCALE() Function

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `TRIM_SCALE()` function to reduce the value's scale by removing trailing zeroes.

## Introduction to the PostgreSQL TRIM_SCALE() function

The `TRIM_SCALE()` function allows you to reduce the scale of a number by removing trailing zeroes.

Note that the scale of a number is a number of fractional decimal digits.

Here's the syntax of the `TRIM_SCALE()` function:

```sql
TRIM_SCALE(numeric_value)
```

In this syntax, the `numeric_value` is a value that you want to trim the scale.

The `TRIM_SCALE()` function returns a numeric value with the numeric type after removing trailing zeroes.

It returns `NULL` if the `numeric_value` is `NULL`.

## PostgreSQL TRIM_SCALE() function examples

Let's take some examples of using the `TRIM_SCALE()` function.

### 1) Basic TRIM_SCALE() function example

The following example uses the `TRIM_SCALE()` function to reduce the trailing zeroes of the number `123.45000`:

```sql
SELECT TRIM_SCALE(123.45000);
```

Output:

```text
 trim_scale
------------
     123.45
(1 row)
```

In this example, the `TRIM_SCALE()` function removes the trailing zeroes from the `123.45`000, resulting in `123.45`.

### 2) Using the TRIM_SCALE() function with table data

We'll show you an example of using the `TRIM_SCALE()` function to standardize the numeric values in a table.

First, [create a table](../postgresql-tutorial/postgresql-create-table) called `products` to store product data:

```sql
CREATE TABLE products (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    price NUMERIC NOT NULL
);
```

Second, [insert some rows](../postgresql-tutorial/postgresql-insert-multiple-rows) into the `products` table:

```sql
INSERT INTO products (name, price)
VALUES
    ('Smartphone', 699.9900),
    ('Laptop', 1299.99),
    ('Headphones', 149.5000),
    ('Tablet', 449.00),
    ('Smartwatch', 299.00),
    ('Wireless Speaker', 79.9900)
RETURNING *;
```

Output:

```text
 id |       name       |  price
----+------------------+----------
  1 | Smartphone       | 699.9900
  2 | Laptop           |  1299.99
  3 | Headphones       | 149.5000
  4 | Tablet           |   449.00
  5 | Smartwatch       |   299.00
  6 | Wireless Speaker |  79.9900
(6 rows)
```

Third, [update](../postgresql-tutorial/postgresql-update) the prices to remove trailing zeroes using the `TRIM_SCALE()` function:

```sql
UPDATE products
SET price = TRIM_SCALE(price)
RETURNING *;
```

Output:

```text
 id |       name       |  price
----+------------------+---------
  1 | Smartphone       |  699.99
  2 | Laptop           | 1299.99
  3 | Headphones       |   149.5
  4 | Tablet           |     449
  5 | Smartwatch       |     299
  6 | Wireless Speaker |   79.99
(6 rows)
```

## Summary

- Use the `TRIM_SCALE()` function to reduce the scale of a number scale by removing trailing zeroes.

---

## Related docs (Math Functions)

- [ABS](https://neon.com/postgresql/postgresql-math-functions/postgresql-abs)
- [CBRT](https://neon.com/postgresql/postgresql-math-functions/postgresql-cbrt)
- [CEIL](https://neon.com/postgresql/postgresql-math-functions/postgresql-ceil)
- [DEGREES](https://neon.com/postgresql/postgresql-math-functions/postgresql-degrees)
- [DIV](https://neon.com/postgresql/postgresql-math-functions/postgresql-div)
- [EXP](https://neon.com/postgresql/postgresql-math-functions/postgresql-exp)
- [FACTORIAL](https://neon.com/postgresql/postgresql-math-functions/postgresql-factorial)
- [FLOOR](https://neon.com/postgresql/postgresql-math-functions/postgresql-floor)
- [GCD](https://neon.com/postgresql/postgresql-math-functions/postgresql-gcd)
- [LCM](https://neon.com/postgresql/postgresql-math-functions/postgresql-lcm)
- [LN](https://neon.com/postgresql/postgresql-math-functions/postgresql-ln)
- [LOG](https://neon.com/postgresql/postgresql-math-functions/postgresql-log)
- [MOD](https://neon.com/postgresql/postgresql-math-functions/postgresql-mod)
- [MIN_SCALE](https://neon.com/postgresql/postgresql-math-functions/postgresql-min_scale)
- [PI](https://neon.com/postgresql/postgresql-math-functions/postgresql-pi-function)
- [POWER](https://neon.com/postgresql/postgresql-math-functions/postgresql-power)
- [RADIANS](https://neon.com/postgresql/postgresql-math-functions/postgresql-radians)
- [RANDOM](https://neon.com/postgresql/postgresql-math-functions/postgresql-random)
- [ROUND](https://neon.com/postgresql/postgresql-math-functions/postgresql-round)
- [SCALE](https://neon.com/postgresql/postgresql-math-functions/postgresql-scale)
- [SIGN](https://neon.com/postgresql/postgresql-math-functions/postgresql-sign)
- [SQRT](https://neon.com/postgresql/postgresql-math-functions/postgresql-sqrt)
- [TRUNC](https://neon.com/postgresql/postgresql-math-functions/postgresql-trunc)
- [WIDTH_BUCKET](https://neon.com/postgresql/postgresql-math-functions/postgresql-width_bucket)
