Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
dev:sql:functions:round [2009/12/07 14:43]
tdo created
dev:sql:functions:round [2016/10/15 04:48] (current)
doc
Line 1: Line 1:
 {{page>:​top_add&​nofooter&​noeditbtn}} {{page>:​top_add&​nofooter&​noeditbtn}}
-<​html><​div align="​center"><​span style="​color:​red">​DRAFT</​span></​div></​html>​ 
-====== Omnidex SQL Function: CASE ====== 
 {{page>:​sql_bar&​nofooter&​noeditbtn}} {{page>:​sql_bar&​nofooter&​noeditbtn}}
 +====== Omnidex SQL Function: ROUND ======
 ===== Description ===== ===== Description =====
-The $ROUND function returns a numeric expression rounded to a specified number of decimal places.+The ROUND function returns a numeric expression rounded to a specified number of decimal places.  If the value specified by n is positive and longer than the digits after the decimal point, 0 is added after the fraction digits. If the value specified by n is negative and larger than or equal to the digits before the decimal point, 0.00 is returned.
  
-If the value specified by n is positive and longer than the digits after the decimal point, 0 is added after the fraction digits. 
- 
-If the value specified by n is negative and larger than or equal to the digits before the decimal point, 0.00 is returned. 
 ===== Syntax ===== ===== Syntax =====
-$ROUND(expression [, n]) 
  
-== expression ​==+ROUND(numeric_expression [, n]) 
 + 
 +== numeric_expression ​==
    
-Required. ​A valid numerical value. This can be a column in a select statement ​that will return ​numerical value.+Required. ​Any expression ​that returns ​numeric expression 
  
 == n == == n ==
    
-Optional. n is an integer indicating the number of digits to the right of the decimal. The default is 0.+Optional. ​//n// is an integer indicating the number of digits to the right of the decimal. The default is 0. 
 ===== Example ===== ===== Example =====
-==== Example 1 ==== +==== Example 1: Column rounded to next higher integer ​==== 
-$ROUND(123.4545, 2)  ​result123.4500+ 
 +<​code>​ 
 + 
 +> select latitude, round(latitude) from countries;​ 
 + 
 +LATITUDE ​                         ​ROUND(COUNTRIES.LATITUDE) 
 +-------------------------------- ​ -------------------------------- 
 +                       ​42.500000 ​                        ​43.000000 
 +                       ​24.000000 ​                        ​24.000000 
 +                       ​33.000000 ​                        ​33.000000 
 +                       ​17.049999 ​                        ​17.000000 
 +                       ​18.209999 ​                        ​18.000000 
 +                       ​41.000000 ​                        ​41.000000 
 +                       ​40.000000 ​                        ​40.000000 
 +</​code>​ 
 + 
 +==== Example 2Column rounded to a set number of decimal places ==== 
 + 
 +Note that floating point values cannot represent ever value, and the values shown below are as close as floating point values can represent. 
 + 
 +<​code>​ 
 +> select latitude, round(latitude,​ 1) from countries;
  
-$ROUND(123.4545-2result: 100.0000+LATITUDE ​                         ​ROUND(COUNTRIES.LATITUDE,1) 
 +-------------------------------- ​ -------------------------------- 
 +                       ​42.500000 ​                        ​42.500000 
 +                       ​24.000000 ​                        ​24.000000 
 +                       ​33.000000 ​                        ​33.000000 
 +                       ​17.049999 ​                        ​17.000000 
 +                       ​18.209999 ​                        ​18.200001 
 +                       ​41.000000 ​                        ​41.000000 
 +                       ​40.000000 ​                        40.000000 
 +</​code>​
  
-$ROUND(123.9994,​ 3)  result: 123.9990+====== Additional Resources ======
  
-$ROUND(123.9995,​ 3)  result124.0000+See also: 
 +{{page>​dev:​sql:​functions:​see_also_math&​noheader&​nofooter&​noeditbtn}}
  
  
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
dev/sql/functions/round.1260197034.txt.gz · Last modified: 2016/06/28 22:38 (external edit)