PostgreSQL FLOOR() Function
The PostgreSQLFLOOR() function returns a number rounded down to the next whole number.
Syntax
The syntax of theFLOOR() function is as follows:
FLOOR(numeric_expression)Arguments
TheFLOOR() function requires one argument:
1)numeric_expression
Thenumeric_expression is a number or an expression that evaluates to a number, which you want to round down.
Return Value
TheFLOOR() function returns a value whose data type is the same as the input argument.
Examples
The following example shows how to use theFLOOR() function to round a number down to the nearest integer:
SELECT FLOOR( 150.75 );The result is:
150See the followingpayment table in thesample database:
The following statement returns the floor of the amount paid by the customer:
SELECT customer_id, FLOOR(SUM( amount )) amount_paidFROM paymentGROUP BY customer_idORDER BY amount_paid DESC;The following picture illustrates the result:

Remarks
To round a number up to the nearest whole number, you use the CEIL() function.
In this tutorial, you have learned how to use the PostgreSQLFLOOR() function to round a number down to the nearest integer, which is less than or equal to the number.
Last updated on