Home > Database > SQL > Usage of floor in sql

Usage of floor in sql

下次还敢
Release: 2024-05-02 01:00:27
Original
1380 people have browsed it

The FLOOR() function in SQL rounds down the specified number. Usage syntax: FLOOR().

Usage of floor in sql

Usage of FLOOR() function in SQL

FLOOR() function is used to round down, that is, Rounds the specified number down to the nearest integer.

Syntax

<code>FLOOR(<数字>)</code>
Copy after login

Where:

  • <Number>: The number to be rounded.

Usage

The usage of the FLOOR() function is very simple. Just pass the number you want to round as an argument to the function.

Example

The following example shows the usage of the FLOOR() function:

<code class="sql">-- 取整数字 12.34
SELECT FLOOR(12.34);  -- 返回 12

-- 取整浮点数 10.5
SELECT FLOOR(10.5);  -- 返回 10

-- 取整负数 -12.34
SELECT FLOOR(-12.34); -- 返回 -13</code>
Copy after login

Notes

  • The FLOOR() function does not round zeros after the decimal point. For example, FLOOR(12.00) returns 12, not 11.
  • FLOOR() function only rounds down. To round up, use the CEIL() function.

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

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template