Difference between revisions of "CEIL"

From SQLZOO
Jump to: navigation, search
(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...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
<p>CEIL(f) give the integer that is equal to, or just higher than f. CEIL always rounds up.</p>  
 
<p>CEIL(f) give the integer that is equal to, or just higher than f. CEIL always rounds up.</p>  
 
<pre style='width:50ex'>
 
<pre style='width:50ex'>
  CEIL(2.7)  ->  2
+
  CEIL(2.7)  ->  3
  CEIL(-2.7) -> -3
+
  CEIL(-2.7) -> -2
 
</pre>
 
</pre>
  
Line 20: Line 20:
 
In this example we calculate the population in millions.
 
In this example we calculate the population in millions.
 
<source lang='sql' class='def e-sqlserver'>  
 
<source lang='sql' class='def e-sqlserver'>  
SELECT name,
+
SELECT population/1000000 AS a,
       FLOOR(population/1000000)
+
       FLOOR(population/1000000) AS b
 
   FROM bbc
 
   FROM bbc
 +
</source>
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
 
SELECT population/1000000 AS a,
 
SELECT population/1000000 AS a,
Line 35: Line 36:
 
   <li>[[MOD |MOD function]]</li>
 
   <li>[[MOD |MOD function]]</li>
 
</ul>
 
</ul>
 +
 +
{{Languages}}

Latest revision as of 10:57, 1 October 2012

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)  ->  3
 CEIL(-2.7) -> -2

In this example we calculate the population in millions.

 
SELECT population/1000000 AS a,
       FLOOR(population/1000000) AS b
  FROM bbc
SELECT population/1000000 AS a,
       CEIL(population/1000000) AS b
  FROM bbc

See also

Language: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense