SQL functions are built into Oracle and are available for use in various appropriate SQL statements. You can also create your own function using PL/SQL.
Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists, WHERE clauses, START WITH and CONNECT BY clauses, and HAVING clauses.
• Number Functions • Character Functions • Miscellaneous Single Row Functions • Aggregate Functions • Date and Time Functions
Number Functions (also known as Math Functions) Number functions accept numeric input and return numeric values. Most of these functions return values that are accurate to 38 decimal digits.
ABS ACOS ASIN ATAN ATAN2 BITAND CEIL COS COSH EXP FLOOR LN LOG MOD POWER ROUND (number) SIGN SIN SINH SQRT TAN TANH TRUNC (number)
ABS returns the absolute value of n. The following example returns the absolute value of -87: SELECT ABS(-87) "Absolute" FROM DUAL;
87
ACOS returns the arc cosine of n. Inputs are in the range of -1 to 1, and outputs are in the range of 0 to pi and are expressed in radians. The following example returns the arc cosine of .3: SELECT ACOS(.3)"Arc_Cosine" FROM DUAL;
1.26610367 Similar to ACOS, you have ASIN (Arc Sine), ATAN (Arc Tangent) functions.
Returns the lowest integer above the given number. Example: The following function return the lowest integer above 3.456; select ciel(3.456) “Ciel” from dual;
4
Returns the highest integer below the given number. Example: The following function return the highest integer below 3.456; select floor(3.456) “Floor” from dual;
3
Returns the cosine of an angle (in radians). Example: The following example returns the COSINE angle of 60 radians. select cos(60) “Cosine” from dual;
Returns the Sine of an angle (in radians). Example: The following example returns the SINE angle of 60 radians. select SIN(60) “Sine” from dual;
Returns the Tangent of an angle (in radians). Example: The following example returns the tangent angle of 60 radians. select Tan(60) “Tangent” from dual; Similar to SIN, COS, TAN functions hyperbolic functions SINH, COSH, TANH are also available in oracle.
Returns the remainder after dividing m with n. Example The following example returns the remainder after dividing 30 by 4. Select mod(30,4) “MOD” from dual;
2
Returns the power of m, raised to n. Example The following example returns the 2 raised to the power of 3. select power(2,3) “Power” from dual;
8
Returns the e raised to the power of n. Example The following example returns the e raised to power of 2. select exp(2) “e raised to 2” from dual;
Returns natural logarithm of n. Example The following example returns the natural logarithm of 2. select ln(2) from dual;
Returns the logarithm, base m, of n. Example The following example returns the log of 100. select log(10,100) from dual;
2
Returns a decimal number rounded of to a given decimal positions. Example The following example returns the no. 3.4573 rounded to 2 decimals. select round(3.4573,2) “Round” from dual;
3.46
Returns a decimal number Truncated to a given decimal positions.
Example The following example returns the no. 3.4573 truncated to 2 decimals. select round(3.4573,2) “Round” from dual;
3.45
Returns the square root of a given number. Example: The following example returns the square root of 16. select sqrt(16) from dual;
4