Dofactory.com
Dofactory.com
Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

SQL FLOOR Function

FLOOR rounds to the nearest integer smaller than the input value.

To round to the nearest integer that is greater use the CEILING function.

Alternatively, use the ROUND function.

Example

#

This example return the nearest integer that is smaller than the input value.

SELECT FLOOR(35.7) AS 'Floor'
Result:  1 record
Floor
35

Syntax

Syntax of the FLOOR function.

FLOOR(value)

value -- a number, variable, or column name.


More Examples

FLOOR on COLUMN

PRODUCT
Id
ProductName
SupplierId
UnitPrice
Package
IsDiscontinued
Problem: List products with prices that are rounded downwards to the nearest dollar. Sort by price.
SELECT ProductName, UnitPrice,
       FLOOR(UnitPrice) AS Floor
  FROM Product
 ORDER BY UnitPrice
Result:  78 records
ProductName UnitPrice Floor
Geitost 2.50 2
Guaraná Fantástica 4.50 4
Konbu 6.00 6
Filo Mix 7.00 7
Tourtière 7.45 7
Rhönbräu Klosterbier 7.75 7

You may also like



Last updated on Dec 21, 2023

Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.