Home >Database >SQL >What does floor mean in sql

What does floor mean in sql

下次还敢
下次还敢Original
2024-05-01 21:51:171012browse

The FLOOR function in SQL is used to round down a number or expression to the nearest integer that is less than or equal to the value. It can be used to round floating point numbers, determine date or time boundaries, round monetary values, and perform interval queries or groupings. The FLOOR function is the opposite of the CEIL function, which rounds numbers upward.

What does floor mean in sql

The meaning of the FLOOR function in SQL

The FLOOR function is a built-in function that is used to round down one The value of a number or expression. This means that it rounds the number to the nearest integer less than or equal to the value.

Syntax

<code>FLOOR(expression)</code>

Where:

  • expression is the number or expression to be rounded.

Example

<code class="sql">SELECT FLOOR(12.5);
-- 结果: 12

SELECT FLOOR(-12.5);
-- 结果: -13

SELECT FLOOR(12.501);
-- 结果: 12</code>

Function

FLOOR function is used in various applications, such as:

  • Round floating point numbers to integers to remove the decimal part.
  • Determine the start or end point of a date or time.
  • Round currency values ​​to avoid small differences.
  • Perform interval query or grouping to divide the data into discrete intervals.

Tip

  • The FLOOR function is the opposite of the CEIL function, which rounds numbers upward.
  • The FLOOR function can be used in conjunction with the CAST function to coerce a number into an integer.
  • The FLOOR function works on negative numbers, but will round down to the nearest smaller integer.

The above is the detailed content of What does floor mean in sql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn