Difference between revisions of "ROUND"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>ROUND(f,p)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''<...")
 
 
Line 29: Line 29:
 
<ul>
 
<ul>
 
   <li>[[FLOOR |FLOOR function]]</li>
 
   <li>[[FLOOR |FLOOR function]]</li>
   <li>[[CEIL function]]</li>
+
   <li>[[CEIL |CEIL function]]</li>
 
   <li>[[MOD |MOD function]]</li>
 
   <li>[[MOD |MOD function]]</li>
 
</ul>
 
</ul>

Latest revision as of 15:24, 16 July 2012

Compatibility
ROUND(f,p)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverYes

ROUND

ROUND(f,p) returns f rounded to p decimal places.

The number of decimal places may be negative, this will round to the nearest 10 (when p is -1) or 100 (when p is -2) or 1000 (when p is -3) etc..

 ROUND(2.7,0) ->  3
 ROUND(2.71,1) ->  2.7

In this example we calculate the population in millions to one demial place.

SELECT name,
       ROUND(population/1000000,1)
  FROM bbc

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense