In order to get Ceil and Floor of column in postgresql we use CEIL() and FLOOR() function. CEIL() Function in postgresql gets round up value. FLOOR() Function in Postgresql get round down value Let’s see how to
- Get round up value in postgresql – CEIL()
- Get Round down value in postgresql – FLOOR()
- Create the column which extracts the ceil and floor of the column
With an example for each
Get CEIL() in Postgresql:
CEIL() function in posgresql gets the round up value
SELECT CEIL(5.7) AS "Ceil";
So the round up value will be
Get FLOOR() in Postgresql:
FLOOR() function in posgresql gets the round down value
SELECT FLOOR(5.7) AS "Floor";
So the round down value will be
We use table states
Get CEIL() of column in Postgresql table:
SELECT *,CEIL(hindex_score) as Ceil_score FROM states
We have created a column and stored CEIL() of hindex_score
So the resultant table will be
Get floor() of column in Postgresql table:
SELECT *,FLOOR(hindex_score) as Floor_score FROM states
We have created a column and stored FLOOR() of hindex_score
So the resultant table will be