Oracle SQL in 10 Minutes - Asim Abbasi

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Chapter 3: SQL Built-in Functions

Page #: 1 | 2 | 3 | 4 | 5


Numeric Functions:

The following functions fall under this category.

ABS
ROUND
SIGN
TRUNC
CEIL
SQRT
FLOOR
MOD

Example:

SELECT ABS(-25) "Result"
FROM DUAL;

Output:

Result
----------
25

Example:

SELECT SIGN(-15) "Result"
FROM DUAL;

Output:

Result
----------
-1

Example:

SELECT CEIL(25.7) "Result"
FROM DUAL;


Output:

Result
----------
26

Example:

SELECT FLOOR(25.7) "Result"
FROM DUAL;

Output:

Result
----------
25


Example:

SELECT ROUND(25.29,1) "Round"
FROM DUAL;

Output:

Round
----------
25.3


SELECT ROUND(25.29,-1) "Round"
FROM DUAL;

Output:

Round
----------
30


Example:

SELECT TRUNC(25.29,1) "Truncate"
FROM DUAL;

Output:

Truncate
----------
25.2


Example:

SELECT TRUNC(25.29,-1) "Truncate"
FROM DUAL;

Output:

Truncate
----------
20

-1 will truncate (make zero) first digit left of the decimal point of 25.29

Example:

SELECT MOD(11,4) "Modulus"
FROM DUAL;

Output:

Modulus
----------
3

Example:

SELECT SQRT(25) "Square root"
FROM DUAL;

Output:

Square root
-----------
5

Chapter 3: SQL Built-in Functions

Page #: 1 | 2 | 3 | 4 | 5

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Share with others: