Use trunc function in insert statement : trunc « Math Functions « PostgreSQL






Use trunc function in insert statement

postgres=# CREATE TABLE numbers (
postgres(#     number         int
postgres(# );
CREATE TABLE
postgres=#
postgres=# INSERT INTO numbers VALUES (trunc(99999.99999999, 6));
INSERT 0 1
postgres=#
postgres=# SELECT * FROM numbers;
 number
--------
 100000
(1 row)

postgres=#
postgres=#
postgres=# drop table numbers;
DROP TABLE
postgres=#

           
       








Related examples in the same category

1.trunc(x): Returns the value of x, with any digits past the decimal point truncated
2.trunc(x, s): Returns the value of x, with any digits past s decimal points truncated