PostgreSQL floor() Function

The PostgreSQL floor() function returns the largest integer value less than or equal to the number specified by the argument.

floor() Syntax

This is the syntax of the PostgreSQL floor() function:

floor(numeric_value) -> integer

Parameters

numeric_value

Required. A number, it can be positive, negative, or zero, it can be an integer or a decimal.

Return value

The PostgreSQL floor() function returns the largest integer value less than or equal to the number specified by the argument. floor() function

The floor() function will return NULL if the argument is NULL.

PostgreSQL will give an error if you supply a parameter that is not a numeric type.

floor() Examples

Here are a few examples of the floor() function:

SELECT
    floor(0) AS "floor(0)",
    floor(10) AS "floor(10)",
    floor(10.11) AS "floor(10.11)",
    floor(-10.11) AS "floor(-10.11)";
 floor(0) | floor(10) | floor(10.11) | floor(-10.11)
----------+-----------+--------------+---------------
        0 |        10 |           10 |           -11