Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL FLOOR Function

by suresh

MySQL FLOOR function is one of the Numeric Functions, which returns the closest integer value that is less than or equal to the specified expression.

The basic syntax of the FLOOR in MySQL is as shown below:

SELECT FLOOR (Numeric_Expression)
FROM Source

To demonstrate this FLOOR Numeric function, we are going to use the below shown data

MySQL FLOOR Function 1

MySQL FLOOR Function Example 1

The MySQL FLOOR returns the closest integer value less than the specified number. The following query shows multiple ways to use the FLOOR function.

-- MySQL FLOOR Function Example

-- Floor Function on Negative Value
SELECT FLOOR(-120.91) AS `Floor Value`;

-- Floor Function on Positive Value
SELECT FLOOR(205.97) AS `Floor Value`;

-- Floor Function on string value
SELECT FLOOR('801.95') AS `Floor Value`;

-- Floor Function on String
SELECT FLOOR('MySQL') AS `Floor Value`;

-- Floor Function on NULLs
SELECT FLOOR('NULL') AS `Floor Value`;

From the below screenshot, you can see that we used MySQL FLOOR function on different values.

MySQL FLOOR Function Example 2

MySQL FLOOR Example 2

The MySQL FLOOR Numeric Function also allows you to find the closest value for the column data. In this example, we are going to find the floor values for all the records present in the Service Grade column.

-- MySQL FLOOR Function Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, FLOOR(StandardCost) AS Cost, 
        Sales, FLOOR(Sales) AS Sales, 
        TaxAmt, FLOOR(TaxAmt) AS Tax,
        ServiceGrade, FLOOR(ServiceGrade) AS Grade
FROM `numeric functions`;

OUTPUT

MySQL FLOOR Function Example 3

MySQL FLOOR WHERE Clause Example

We can also use this MySQL FLOOR in Where Clause as well. In this example, we use Floor function in where clause to restrict the records selected by the SELECT Statement.

-- MySQL FLOOR Function Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, FLOOR(StandardCost) AS Cost, 
        Sales, FLOOR(Sales) AS Sales, 
        TaxAmt, FLOOR(TaxAmt) AS Tax,
        ServiceGrade, FLOOR(ServiceGrade) AS Grade
FROM `numeric functions`
WHERE FLOOR(TaxAmt) > 200;

OUTPUT

MySQL FLOOR Function Example 4

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy