In order to truncate the value of column in postgresql we use TRUNC() function. TRUNC() Function in postgresql truncates the value. Let’s see how to
- Truncate the value in postgresql – TRUNC()
- Truncate the value to decimal places in postgresql
- Create the column which truncates the value of the column
With an example for each
Get TRUNC() in Postgresql:
TRUNC() function in posgresql gets the truncated value
SELECT TRUNC(5.7) AS "Truncate_hindex";
So the truncated value will be
SELECT TRUNC(5.69677,2) AS "Truncate_hindex";
The truncated value will be for two decimal places
Get truncated value of column in Postgresql table:
We use table states
SELECT *,TRUNC(hindex_score) as Truncate_hindex from STATES
We have created a column and stored truncated value of hindex_score
So the resultant table will be
Truncate the column to decimal places in Postgresql table:
Truncate the column to two decimal places as shown below
SELECT *,TRUNC(hindex_score,2) as Truncate_hindex from STATES
We have created a column and stored the truncated value of hindex_score to two decimal places
So the resultant table will be