scale()

A function returning the scale of the argument

scale() is a system function which returns the scale of the argument (the number of decimal digits in the fractional part).

scale() was added in PostgreSQL 9.6.

Usage

scale ( numeric ) → integer

From PostgreSQL 13, the function min_scale() is available, which does the same thing but removes any trailing zeroes.

Change history

Examples

Execution examples for scale():

postgres=# SELECT scale(1.2300);
 scale
-------
     4
(1 row)

postgres=# SELECT scale(1.23);
 scale
-------
     2
(1 row)

postgres=# SELECT scale(1.0);
 scale
-------
     1
(1 row)

postgres=# SELECT scale(1);
 scale
-------
     0
(1 row)

Categories

System function

See also

min_scale(), trim_scale()