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
    • SQL FAQ’s

MySQL CEILING Function

by suresh

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

The basic syntax of the CEIL or CEILING in MySQL is as shown below:

-- MySQL CEILING Function Syntax
SELECT CEILING (Numeric_Expression)
FROM Source

-- MySQL CEILING Function Syntax
SELECT CEIL (Numeric_Expression)
FROM Source

To demonstrate the CEIL or CEILING Numeric function, we are going to use the below shown data

MySQL CEILING Function 1

MySQL CEILING Function Example 1

The CEILING Function displays the closest integer value. The following query shows multiple ways to use the CEILING function.

-- MySQL CEILING Function Example

-- Ceiling Function on Negative Value
SELECT CEILING(-1150.01) AS `Ceiling Value`;

-- Ceiling Function on Positive Value
SELECT CEILING(125.07) AS `Ceiling Value`;

-- Ceiling Function on string value
SELECT CEILING('712.17') AS `Ceiling Value`;

-- Ceiling Function on String
SELECT CEILING('MySQL') AS `Ceiling Value`;

-- Ceiling Function on NULLs
SELECT CEILING('NULL') AS `Ceiling Value`;

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

MySQL CEILING Function Example 2

MySQL CEIL Function Example

The MySQL CEIL Function is the synonym for the ceiling Numeric Function. The following query shows you the CEIL function examples.

-- MySQL CEIL Function Example

-- Ceil Function on Negative Value
SELECT CEIL(-19.91) AS `Ceil Value`;

-- Ceil Function on Positive Value
SELECT CEIL(25.02) AS `Ceil Value`;

-- Ceil Function on string value
SELECT CEIL('1415.19') AS `Ceil Value`;

From the screenshot below, you can see we used the CEIL function on different values.

MySQL CEILING Function Example 3

MySQL CEILING Example 2

The MySQL CEILING or CEIL also allows you to find the closest value for the column data. In this MySQL example, we are going to find the closet integer values for all the records present in the Service Grade column.

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

OUTPUT

MySQL CEILING Function Example 4

MySQL CEILING WHERE Clause Example

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

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

OUTPUT

MySQL CEILING Function Example 5

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