Home > SQL, Technical > Mathematical functions in Oracle SQL

Mathematical functions in Oracle SQL

July 26, 2012

Function 1: ROUND

Purpose :  Round off to the nearest wholenumber

Syntax : Round(number)

Example1 : SELECT ROUND(11.11456), ROUND(11.89456) FROM DUAL;

Output1:  11 , 12

Example2 : SELECT ROUND(11.11456,2), ROUND(11.89456,-1) FROM DUAL;

Output2:  11 , 10

———————————————————————————————-

Function 2: TRUNC

Purpose :  round the number towards zero

Syntax : trunc(number)

Example1 : SELECT trunc(11.11456),trunc(11.89456) FROM DUAL;

Output1:  11 , 11

Example2 : SELECT TRUNC(11.11456,2), TRUNC(11.89456,-1) FROM DUAL;

Output2:  11 , 10

———————————————————————————————

Function 3: REMAINDER

Purpose :  In a division, get the remainder of the number

Syntax : remainder(number1,number2)

Example1 : SELECT REMAINDER(9,3),REMAINDER(10,3),REMAINDER(11,3) FROM DUAL;

Output1:  0,1,-1

———————————————————————————————

Function 4: MOD

Purpose :  Does the modulo division operation

Syntax : mod(number1,number2)

Example1 : SELECT MOD(9,3),MOD(10,3),MOD(11,3) FROM DUAL;

Output1:  0,1,2

 

Advertisements
Categories: SQL, Technical
%d bloggers like this: