Numerical Functions for Oracle Database

rounded up

1. Grammar
ROUND(n[,m])
Omit m: 0
m>0: m digits after the decimal point
m<0: m digits before the decimal point
n represents the value to be rounded.
m indicates the number of digits after or before the decimal point to be retained.
2. Examples
  1. SQL>select round(23.4),round(23.45,1),round(23.45,-1)from dual;
  2. ROUND(23.4) ROUND(23.45,1) ROUND(23.45,-1)
  3. ----------------------------------------
  4. 2323.520
 
Two rounding function
1. Grammar
CEIL (n)
FLOOR(n)
2. Examples
  1. SQL>select ceil(23.45),floor(23.45)from dual;
  2. CEIL(23.45) FLOOR(23.45)
  3. -----------------------
  4. 2423
 
Three commonly used calculation functions
1. Grammar
ABS(n)
MOD(m,n): If there is a null value in m and n, the result returns null.
POWER(m,n): Indicates the n-th power of m.
SQRT(n): find the square root
2. Examples
  1. SQL>select abs(23.45),abs(-23),abs(0)from dual
  2. 2;
  3. ABS(23.45) ABS(-23) ABS(0)
  4. ------------------------------
  5. 23.45230
  6. SQL>select mod(5,2)from dual;
  7. MOD(5,2)
  8. ----------
  9. 1
  10. SQL>select mod(5,null)from dual;
  11. MOD(5,NULL)
  12. -----------
  13. SQL>select power (2,3),power(null,3)from dual;
  14. POWER(2,3) POWER(NULL,3)
  15. -----------------------
  16. 8
  17. SQL>select sqrt(16)from dual;
  18. SQRT(16)
  19. ----------
  20. 4
 
Four trigonometric functions
1. Grammar
SIN (n) 、 ASIN (n)
COS(n)、ACOS(n)
TAN(n)、ATAN(n)
2. Examples
  1. SQL>select sin(1.57)from dual;
  2. SIN(1.57)
  3. ----------
  4. .999999683
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326173026&siteId=291194637