Follow us: Connect on YouTube Connect on YouTube Connect on YouTube

Pages

Thursday, 31 March 2016

SQL-Mod



This will give the remainder.

     Syntax: mod (value, divisor) 

     Example:
          SQL> select mod(7,4), mod(1,5), mod(null,null), mod(0,0), mod(-7,4) from dual;

              MOD(7,4)   MOD(1,5) MOD(NULL,NULL)   MOD(0,0)  MOD(-7,4)
   ------------      ----------      ---------------------       ----------- -------------
             3                  1                                                     0         -33



You May Like                                             
                            SQL Abs
                            SQL Sign
                            SQL Sqrt                           
                            SQL NVL
                            SQL NVL2
                            SQL Power
                            SQL Exp
                            SQL Ln
                            SQL Log
                            SQL CEIL
                            SQL Floor
                            SQL Round
                            SQL Trunc
                            SQL Bitand
                            SQL Greatest
                            SQL Least
                            SQL Coalesce

Share this article :

2 comments:

  1. Hi There,

    Grazie! Grazie! Grazie! Your blog is indeed quite interesting around
    Oracle Appplications I agree with you on lot of points!

    I have one hierarchy query for tables exchange_grp and node.
    Second hierarchy query for tables node and node_side.

    SELECT E.P_K, E.I4030_EXCH_GRP_CD, N.P_K, N.I4020_NODE_ID, N.I4020_NODE_CAT, LEVEL
    FROM WORK_REP.EXCHANGE_GRP E, WORK_REP.NODE N
    WHERE E.P_K = N.FK_S_EXGRP_NODE
    AND E.I4030_EXCH_GRP_TYPE = 'SVX'
    START WITH N.P_K IN E.NK_S_EXGRP_NODE
    CONNECT BY NOCYCLE N.P_K = PRIOR N.NK_S_EXGRP_NODE

    and

    SELECT N.P_K, NS.P_K, NS.FK_S_NODE_NSIDE, NS.I4040_SIDE_TYPE, LEVEL
    FROM WORK_REP.NODE N, WORK_REP.NODE_SIDE NS
    WHERE N.P_K = NS.FK_S_NODE_NSIDE
    START WITH NS.P_K IN N.NK_S_NODE_NSIDE
    CONNECT BY NOCYCLE NS.P_K = PRIOR NS.NK_S_NODE_NSIDE

    Can we combine these two queries into one.

    It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
    Keep up the good work!

    Thanks a heaps,
    Preethi

    ReplyDelete
  2. Salaam,


    A really interesting, clear and easily readable Oracle SQL, PL/SQL, Linux article of interesting and different perspectives.I will clap. So much is so well covered here.


    I have a job which picks a record from a cursor and then it calls a stored procedure which processes the record picked up from the cursor.

    The stored procedure has multiple queries to process the record. In all, procedure takes about 0.3 seconds to process a single record picked up by the cursor but since cursor contains more than 1 Lac records it takes hours to complete the job.

    The queries in the stored procedure are all optimized

    I was thinking of making the procedure run in multi threaded way as in java and other programming language.
    Can it be done in oracle? or is there any other way I can reduce the run time of my job.

    Follow my new blog if you interested in just tag along me in any social media platforms!


    ,Merci
    Radhey

    ReplyDelete