SQLite 3 reference · Math Functions

SQLite FLOOR() Function

Return the largest integer value not greater than a number, rounding down: floor(2.9) is 2 and floor(-2.1) is -3.

SQLite 3 Since 3.35.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

floor(X)

Parameters

ParameterDescription
X A number (text that looks like a number is converted).

Return value

An integer for integer input, otherwise a floating-point number.

Examples

Round down
SELECT floor(2.9) AS a, floor(-2.1) AS b;

Output

a | b
2 | -3

Run this on your computer — see “Get Started” for setup.

Group into bands of 10
SELECT name, floor(price / 10) * 10 AS price_band
FROM products
LIMIT 4;

Output

name | price_band
SQL for Beginners | 20
Clean Code | 30
The Pragmatic Programmer | 40
Mechanical Keyboard | 80

Run this on your computer — see “Get Started” for setup.

This is one of SQLite's built-in math functions, available since 3.35.0 when SQLite is compiled with SQLITE_ENABLE_MATH_FUNCTIONS (the default for the sqlite3 command-line tool and most language bindings). The in-browser SQLite on this site is built without them, so the examples show output from standard SQLite instead.

Version history

VersionChange
SQLite 3.35.0Added

In other languages

Was this page helpful?