FLOOR() function returns a number rounded down to the next whole number.
The syntax of the
FLOOR() function is as follows:
FLOOR() function requires one argument:
The numeric_expression is a number (or an expression which evaluates to a number) that is rounded down.
FLOOR() function returns a value whose data type is the same as the input argument.
The following example shows how to use the
FLOOR() function to round a number down to the nearest integer:
FLOOR( 150.75 );
The result is:
See the following
payment table in the sample database:
The following statement returns the floor of amount paid by customer:
FLOOR(SUM( amount )) amount_paid
The following picture illustrates the result:
To round a number up to the nearest whole number, you use the
In this tutorial, you have learned how to use the PostgreSQL
FLOOR() function to round a number down to the nearest integer, which is less than or equal to the number.