Movatterモバイル変換


[0]ホーム

URL:


You don’t need a vector database - just use Postgres for everything. Read the case study on switching from Pinecone to Neon
PostgreSQL Tutorial
PostgreSQL Tutorial

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:

150

See the followingpayment table in thesample database:

payment tableThe 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:

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

Last updated on

Was this page helpful?
Thank you for your feedback!

[8]ページ先頭

©2009-2025 Movatter.jp