Ceil and Floor of column in Postgresql (Round up & Round down)

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

Ceil and Floor of column in Postgresql 1

 

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

Ceil and Floor of column in Postgresql 2

We use table states

Ceil and Floor of column in Postgresql 5

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

Ceil and Floor of column in Postgresql 3

 

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

Ceil and Floor of column in Postgresql 4