PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL Math Functions / PostgreSQL FLOOR Function

PostgreSQL FLOOR Function

The PostgreSQL FLOOR() function returns a number rounded down to the next whole number.

Syntax

The syntax of the FLOOR() function is as follows:

1
FLOOR(numeric_expression)

Arguments

The FLOOR() function requires one argument:

1) numeric_expression

The numeric_expression is a number (or an expression which evaluates to a number) that is rounded down.

Return Value

The FLOOR() function returns a value whose data type is the same as the input argument.

Examples

The following example shows how to use the FLOOR() function to round a number down to the nearest integer:

1
2
SELECT
    FLOOR( 150.75 );

The result is:

1
150

See the following payment table in the sample database:

payment table

The following statement returns the floor of amount paid by customer:

1
2
3
4
5
6
7
8
9
SELECT
    customer_id,
    FLOOR(SUM( amount )) amount_paid
FROM
    payment
GROUP BY
    customer_id
ORDER BY
    amount_paid DESC;

The following picture illustrates the result:

PostgreSQL FLOOR Function Example

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 PostgreSQL FLOOR() function to round a number down to the nearest integer, which is less than or equal to the number.

Previous Tutorial: PostgreSQL MOD Function
Next Tutorial: PostgreSQL TRUNC Function

PostgreSQL Math Functions

  • ABS
  • CEIL
  • MOD
  • FLOOR
  • ROUND
  • TRUNC

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL ANY Operator
  • PostgreSQL EXISTS
  • How To Delete Duplicate Rows in PostgreSQL
  • PostgreSQL TO_CHAR Function
  • PostgreSQL TO_NUMBER Function
  • PostgreSQL TO_TIMESTAMP Function
  • PostgreSQL CEIL Function
  • PostgreSQL MOD Function
  • PostgreSQL FLOOR Function
  • PostgreSQL ABS Function

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.