CEIL

From SQLZOO
Revision as of 10:05, 16 July 2012 by Connor (Talk | contribs) (Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>CEIL(f)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Compatibility
CEIL(f)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverNoFLOOR(-f)

CEIL

CEIL(f) is ceiling, it returns the integer that is equal to or just more than f

CEIL(f) give the integer that is equal to, or just higher than f. CEIL always rounds up.

 CEIL(2.7)  ->  2
 CEIL(-2.7) -> -3

In this example we calculate the population in millions.

 
SELECT name,
       FLOOR(population/1000000)
  FROM bbc
<SOURCE lang='sql' class='def'>
SELECT population/1000000 AS a,
       CEIL(population/1000000) AS b
  FROM bbc

See also