InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference  /  SQL Functions

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

A numeric function that returns the smallest integer greater than or equal to a given numeric expression.
{fn CEILING(numeric-expression)}
numeric-expression A number whose ceiling is to be calculated.
CEILING returns the same data type as numeric-expression.
CEILING returns the nearest integer value greater than or equal to numeric-expression. The returned value has a scale of 0. When numeric-expression is a NULL value, an empty string (''), or any nonnumeric string, CEILING returns NULL.
Note that CEILING can be invoked as an ODBC scalar function (with the curly brace syntax) or as an SQL general function.
This function can also be invoked from ObjectScript using the CEILING() method call:
The following examples show how CEILING converts a fraction to its ceiling integer:
SELECT CEILING(167.111) AS CeilingNum1,
       CEILING(167.456) AS CeilingNum2,
       CEILING(167.999) AS CeilingNum3
all return 168.
SELECT {fn CEILING(167.00)} AS CeilingNum1,
       {fn CEILING(167.00)} AS CeilingNum2
return 167.
SELECT CEILING(-167.111) AS CeilingNum1,
       CEILING(-167.456) AS CeilingNum2,
       CEILING(-167.999) AS CeilingNum3
all return -167.
SELECT CEILING(-167.00) AS CeilingNum 
returns -167.
The following example uses a subquery to reduce a large table of US Zip Codes (postal codes) to one representative city for each ceiling Latitude integer:
SELECT City,State,CEILING(Latitude) AS CeilingLatitude 
FROM (SELECT City,State,Latitude,CEILING(Latitude) AS CeilingNum
      FROM Sample.USZipCode)
GROUP BY CeilingNum
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-20 05:47:55