1 2 Previous Next 17 Replies Latest reply: Sep 6, 2012 9:32 AM by BluShadow

# modulo & div Functions

Hi,
can anyone tells me if there is the div function in oracle ??
mod is the reste of division : mod(15,2)=1 this is ok in oracle
and the div is the result of the devision
is there this function ???
• ###### 1. Re: modulo & div Functions
Hi,

U can still use / for div in oracle as well.
``  select 14/2 from dual ``
Yes mod gives the remainder.

-knick
• ###### 2. Re: modulo & div Functions
no there is no such function in oracle

only MOD is there

for division use simple
SQL> select 15/2 as answer from dual;
7.5
• ###### 3. Re: modulo & div Functions
Hi,

To get the integer results of division, use TRUNC (a / b).
For example, TRUNC (15 / 2) returns 7.
TRUNC (-15 / 2) returns -7.
• ###### 4. Re: modulo & div Functions
trunc(a/b)
• ###### 5. Re: modulo & div Functions
HI it is trunc(15/2) from dual;
• ###### 6. Re: modulo & div Functions
Hi
this doesn't reture the div
i mean
SELECT 15/2 from dual; ---> 7.5
& my SELECT abs(15/2) from dual; ---> 7.5 too???
• ###### 7. Re: modulo & div Functions
Hi abs function returns a positive value so if the answer is already positive then it will return as it is.

select abs(-15/2) from dual; then the answer is 7.5

where as select -15/2 from dual will give -7.5 as the answer.

I hope it is clear about the ABS function.
• ###### 8. Re: modulo & div Functions
Merci

Edited by: user604761 on 28 mai 2009 07:21
• ###### 9. Re: modulo & div Functions
oracle_for_dude wrote:
HI it is trunc(15/2) from dual;
Is it?
``````SQL>var v number
SQL>exec :v:= trunc(15/2)

PL/SQL procedure successfully completed.

SQL>print v

V
----------
7

SQL>``````
Strange to comment that way to a guru, especially after giving a not so correct answer, yourself.

Regards
Peter
• ###### 10. Re: modulo & div Functions
Hi please read the complete thread , trunc(15/2) is for integer value I wrote that in response to frank kulash post where by mistake he has writtten trunc(15,2) instead of trunc(15/2); I hope it is clear
• ###### 11. Re: modulo & div Functions
Hi dude,

Sorry if I was mistaken, can't see that now.

I only responded to your "from dual" and the fact that you seem to believe that division OPERATOR is the same as div FUNCTION.

Regards
Peter
• ###### 12. Re: modulo & div Functions
Hi no problem he might have changed that when you saw it.

:)
• ###### 13. Re: modulo & div Functions
I just tried select div(13,2) from dual and it worked.
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production.
• ###### 14. Re: modulo & div Functions
dba_vijay wrote:
I just tried select div(13,2) from dual and it worked.
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production.
You must have something special that I don't:

=======================
SYS@DEV1>select * from v\$version;

BANNER
----------------------------------------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Solaris: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

5 rows selected.

SYS@DEV1>select div(13,2) from dual;
select div(13,2) from dual
*
ERROR at line 1:
ORA-00904: "DIV": invalid identifier
=======================
1 2 Previous Next