Rectifying Divide By 0 query

The following is part of my SELECT clause that is giving me divide by 0 error:
[TotalHours]/SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) AS 'MTBF'
Im trying to rectify the divide by 0 like this:
[TotalHours]/CASE WHEN SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) = 0 THEN 1 ELSE SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) AS 'MTBF'
However the above statement is giving me red squigglies under 'AS'
May somebody please offer a suggestion on how to rectify this?
Thanks.

I think missing END at the end of statement.
[TotalHours]/CASE WHEN SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) = 0 THEN 1 ELSE SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) END AS 'MTBF'
-Igor

Similar Messages

  • Query handled OK on Oracle server but XSQL Servlet raises OracleXMLSQLException

    After dropping and recreating certain object types, and then using ALTER TYPE on an object dependent on those object types, XSQL Servlet raises exception for a query that is handled fine in the Oracle Server itself (ie, in SQL*Plus) as in the following test case:
    create or replace type o_object_inner as object( char1 char(1) )
    create or replace type n_nested_table as table of o_object_inner
    create or replace type o_object_outer as object (nNestedTab n_nested_table)
    For above, the following query encounters no problems on Oracle Server or in XSQL servlet:
    Select o_object_outer(NULL) as "theOuterObj" from dual
    But then if object types are modified as follows:
    drop type o_object_inner force
    create or replace type o_object_inner as object( char1 char(1) ) --same as above
    drop type n_nested_table force
    create or replace type n_nested_table as table of o_object_inner --same as above
    alter type o_object_outer compile
    The above query now encounters no problems in SQL*Plus but generates exception in XSQL servlet as follows:
    oracle.xml.sql.OracleXMLSQLException: Internal Error: Unable to resolve name
    More complex cases generated the above exception and/or the following exception:
    oracle.xml.sql.OracleXMLSQLException: Internal Error: Invalid ADT attribute
    Any insight or help would be greatly appreciated!
    Other info:
    Oracle Server 8.1.7.3 on HP-UX
    XDK 9.2.0.1 (Production) for Java on NT
    JDBC/OCI8 drivers for NT (latest for 8.1.7)

    Yes,
    I changed most of the cursor functions to cast(multiset()). Sometimes i divided a big query into two or three queries (when there was cursor nested in a cursor). It was one day work for me. Don't forget to change the tags with ROW to ITEM in your xsl-stylesheets.
    Uwe

  • Permission to use BPMaster object

    Hi
    I am working on SAP 2005A SP01 i have made some changes in users Permission and I am encountering a big problem while creating an object of Business partner Master Data. I get a SBO error message saying "The Loged On user does not have permission to use this object". I have tried hard to rectify it and have even discussed it on forums but have not received any valid solution to this. Anyone from you who has experienced this problem before and has rectified it(without using query object) do let me know If there is no solution available in this version then by which version of SAPb1 can we expect this problem to be overcome.

    Hi Pradeep,
    No, unfortunately, I think you've got to give full authorisation for BPs to the current user if you wish to use the BP object in the DI. Your choices are really only limited to Full or No authorisations.
    As for future versions, I haven't heard that the authorisations will have changed in version 2007 so it could be a long time before you see the functionality you'd like. You can always log a DRQ with SAP, requesting such a change (the more DRQs that SAP receive on a particular issue, the higher its priority for inclusion in a future version).
    Kind Regards,
    Owen

  • Difference in Hierarchy node data

    hi experts,
    i have an issue related to the data display in a query. I had executed a query which displays the data on the basis of Hierarchy of Cost center. in total of Hierarchy ie, the at the root node of the hier. the data is coming 3000k against a GL Account where as when i expend that node there is only one cost center exists that has some different figure against the same GL account 5000K.
    Next day the figures were rectified by itsellf
    the query is developed on MP & it includes the cube of actual data in which data is extracted on hourly basis. also cube has aggregates.
    i wonder why this is happening?? can anyone advice the suggestion??
    do i need to work on aggregates also? is it possible that aggregates become corrupt?? if so, then how can they be rectified??
    thanks in advance
    Neha

    Hi Neha.
    Some thoughts:
    Maybe for the hierarchy you are suppressing the "nodesnotconnected", which is the residual node where all the costcenters that are not explicitly assigned to the hierarchy are placed. In this case, I think the total on the hierarchy root will also include the postings from the nodesnotconnected, but because you are suppressing it you cannot see the "missing" 2000 anywhere.
    So, let's assume that the 2000 where posted to a costcenter that for some reason is not assigned to the hierarchy. The next day, someone realised that it was posted to the wrong costcenter, reverses the posting and puts the 2000 on the correct costcenter, which is in fact assigned to the hierarchy. Now you load the data, and voila, the numbers match.
    Something like this maybe?
    Regards
    Jacob

  • JOIN optimize PROJ - AFRU

    Hi,
    Has anybody idea if it is possible to optimize this query?
    I suppose that join should be the best, what I can get... but it is still very very slow. I need data from AFRU, AFVC, AFVV per project num (PROJ), so there are thousands of lines in result. Now I am able to get data only per one AUFNR(AFPO) - few minutes, per POSID(PRPS) or PSPID(PROJ) it falls down after 10 minutes.
    Is it better to divide so difficult query or use another techniques? Or change order of tables in query?
    Thanks for help  in advance.
    SELECT projpspid prpsposid afruaufnr afpomatnr maktmaktx afpoaufnr
          afvcvornr afvcltxa1 afvvmgvrg crhdarbpl crtxktext afvvvgw01
          afvvvgw02 afrulmnga afruism01 afruism02 afruersda afruernam
          afrupernr afrurueck afruile01 afvvvge01 afvv~meinh
        INTO CORRESPONDING FIELDS OF TABLE it_zppprodtime
        FROM afru
        INNER JOIN afpo
          ON afruaufnr = afpoaufnr
        INNER JOIN prps
          ON afpoprojn = prpspspnr
        INNER JOIN proj
          ON prpspsphi = projpspnr
        INNER JOIN crhd
          ON crhdobjid = afruarbid
        INNER JOIN afvc
          ON afvcaufpl = afruaufpl
            AND afvcaplzl = afruaplzl
        INNER JOIN afvv
          ON afvvaufpl = afruaufpl
            AND afvvaplzl = afruaplzl
        INNER JOIN makt
          ON maktmatnr = afpomatnr
        INNER JOIN crtx
          ON crtxobjid = crhdobjid
        WHERE
          proj~pspid IN s_pspid
          AND prps~posid IN s_projn
          AND crhd~arbpl IN s_arbpl
          AND afru~aufnr IN s_aufnr
          AND makt~spras = 'CS'
          and crtx~spras = 'CS'.

    Hi Martin,
    I had a few concerns.
    1) In real life it is unlikely that that you will get users to make queries on all the orders. It appears more likely to me that users would enter a project number/s in the selection screen. Given that it makes more sense constructing your query to begin with project number rather than order number. I have taken the liberty of modifying the query to give you an example.
    2) I noticed that your query reads table CRHD using field OBJID. The primary key is based on fields OBJTY and OBJID. If you know the OBJTY you can use it in the where clause. This will let you use the primary key. Remember CRHD is a huge table.
    3) You can use the OBJID from CRHD table to join table CRTX. (Look at the query below).
    SELECT proj~pspid
           prps~posid
           afru~aufnr
           afpo~matnr
           makt~maktx
           afpo~aufnr
           afvc~vornr
           afvc~ltxa1
           afvv~mgvrg
           crhd~arbpl
           crtx~ktext
           afvv~vgw01
           afvv~vgw02
           afru~lmnga
           afru~ism01
           afru~ism02
           afru~ersda
           afru~ernam
           afru~pernr
           afru~rueck
           afru~ile01
           afvv~vge01
           afvv~meinh
    INTO CORRESPONDING FIELDS OF TABLE it_zppprodtime
    FROM       proj
    inner join prps
    on  prps~psphi = proj~pspnr
    inner join afpo
    ON  afpo~projn = prps~pspnr
    inner join afru
    on  afru~aufnr = afpo~aufnr
    INNER JOIN afvc
    ON  afvc~aufpl  = afru~aufpl
    AND afvc~aplzl = afru~aplzl
    INNER JOIN afvv
    ON  afvv~aufpl = afru~aufpl
    AND afvv~aplzl = afru~aplzl
    INNER JOIN makt
    ON  makt~matnr = afpo~matnr
    INNER JOIN crhd
    ON  crhd~objid = afru~arbid
    INNER JOIN crtx
    ON  crtx~objTY = crhd~objty
    AND crtx~objid = crhd~objid
    WHERE proj~pspid IN s_pspid
    AND   prps~posid IN s_projn
    AND   crhd~arbpl IN s_arbpl
    AND   afru~aufnr IN s_aufnr
    AND   makt~spras = 'CS'
    AND   crhd~objty = ????
    AND   crtx~spras = 'CS'.

  • MAIN DIFFERENCES BETWEEN PARALLEL AND SEQUENTAIL PRCESSING???

    HI PALS,
    I WANT THE COMPLETE DIFFERENCES BETWEEN PARALLEL AND SEQUENTIAL PROCESSING!
    IN THE CONTEXT OF RFC.

    Hi
    Parallel Processing
    To achieve a balanced distribution of the system load, you can use destination additions to execute function modules in parallel tasks in any application server or in a predefined application server group of an SAP system.
    Parallel-processing is implemented with a special variant of asynchonous RFC. Itu2019s important that you use only the correct variant for your own parallel processing applications: the CALL FUNCTION STARTING NEW TASK DESTINATION IN GROUP keyword. Using other variants of asynchronous RFC circumvents the built-in safeguards in the correct keyword, and can bring your system to its knees
    Details are discussed in the following subsections:
    ·        Prerequisites for Parallel Processing
    ·        Function Modules and ABAP Keywords for Parallel Processing
    ·        Managing Resources in Parallel Processing
    Prerequisites for Parallel Processing
    Before you implement parallel processing, make sure that your application and your SAP system meet these requirements:
    ·        Logically-independent units of work:
    The data processing task that is to be carried out in parallel must be logically independent of other instances of the task. That is, the task can be carried out without reference to other records from the same data set that are also being processed in parallel, and the task is not dependent upon the results of others of the parallel operations. For example, parallel processing is not suitable for data that must be sequentially processed or in which the processing of one data item is dependent upon the processing of another item of the data.
    By definition, there is no guarantee that data will be processed in a particular order in parallel processing or that a particular result will be available at a given point in processing. 
    ·        ABAP requirements:
    ¡        The function module that you call must be marked as externally callable. This attribute is specified in the Remote function call supported field in the function module definition (transaction SE37).
    ¡        The called function module may not include a function call to the destination u201CBACK.u201D
    ¡        The calling program should not change to a new internal session after making an asynchronous RFC call. That is, you should not use SUBMIT or CALL TRANSACTION in such a report after using CALL FUNCTION STARTING NEW TASK.  
    ¡        You cannot use the CALL FUNCTION STARTING NEW TASK DESTINATION IN GROUP keyword to start external programs. 
    ·        System resources: 
    In order to process tasks from parallel jobs, a server in your SAP system must have at least 3 dialog work processes. It must also meet the workload criteria of the parallel processing system: Dispatcher queue less than 10% full, at least one dialog work process free for processing tasks from the parallel job.
    Function Modules and ABAP Keywords for Parallel Processing
    You can implement parallel processing in your applications by using the following function modules and ABAP keywords:
    ·        SPBT_INITIALIZE: Optional function module. 
    Use to determine the availability of resources for parallel processing. 
    You can do the following:
    ¡        check that the parallel processing group that you have specified is correct.
    ¡        find out how many work processes are available so that you can more efficiently size the packets of data that are to be processed in your data.
    ·        CALL FUNCTION Remotefunction STARTING NEW TASK Taskname DESTINATION IN GROUP:
    With this ABAP statement, you are telling the SAP system to process function module calls in parallel. Typically, youu2019ll place this keyword in a loop in which you divide up the data that is to be processed into work packets. You can pass the data that is to be processed in the form of an internal table (EXPORT, TABLE arguments). The keyword implements parallel processing by dispatching asynchronous RFC calls to the servers that are available in the RFC server group specified for the processing.
    Note that your RFC calls with CALL FUNCTION are processed in work processes of type DIALOG. The DIALOG limit on processing of one dialog step (by default 300 seconds, system profile parameter rdisp/max_wprun_time) applies to these RFC calls. Keep this limit in mind when you divide up data for parallel processing calls. 
    ·        SPBT_GET_PP_DESTINATION: Optional function module. 
    Call immediately after the CALL FUNCTION keyword to get the name of the server on which the parallel processing task will be run. 
    ·        SPBT_DO_NOT_USE_SERVER: Optional function module. 
    Excludes a particular server from further use for processing parallel processing tasks. Use in conjunction with SPBT_GET_PP_DESTINATION if you determine that a particular server is not available for parallel processing (for example, COMMUNICATION FAILURE exception if a server becomes unavailable).
    ·        WAIT: ABAP keyword
    WAIT UNTIL
    Required if you wish to wait for all of the asynchronous parallel tasks created with CALL FUNCTION to return. This is normally a requirement for orderly background processing. May be used only if the CALL FUNCTION includes the PERFORMING ON RETURN addition.
    ·        RECEIVE: ABAP keyword
    RECEIVE RESULTS FROM FUNCTION Remotefunction
    Required if you wish to receive the results of the processing of an asynchronous RFC. RECEIVE retrieves IMPORT and TABLE parameters as well as messages and return codes.
    Managing Resources in Parallel Processing
    You use the following destination additions to perform parallel execution of function modules (asynchronous calls) in the SAP system:
    In a predefined group of application servers:
    CALL FUNCTION Remotefunction STARTING NEW TASK Taskname
    DESTINATION IN GROUP Groupname
    In all currently available and active application servers:
    CALL FUNCTION Remotefunction STARTING NEW TASK Taskname
    DESTINATION IN GROUP DEFAULT
    Sequential Processing
    In the following cases, the system chooses sequential (non-parallel) processing:
    ●      In table RSADMIN, entry QUERY_MAX_WP_DIAG has value (column value) 1.
    ●      The entire query consists of one sub-access only.
    ●      The query is running in a batch process.
    ●      The query was started from the query monitor (transaction RSRT) using various debug options (for example, SQL query display, execution plan display). See, Dividing a MultiProvider Query into Sub-Queries.
    ●      The query requests non-cumulative key figures.
    ●      Insufficient dialog processes are available when the query is executed. These are required for parallel processing.
    ●      The query is configured for non-parallel processing.
    ●      You want to save the result of the query in a file or a table.
    In Release SAP NetWeaver 7.0, the system can efficiently manage the large intermediate results produced by parallel processing. In previous releases, the system terminated when it reached a particular intermediate result size and proceeded to read data sequentially. This is no longer the case. Therefore, the RSADMIN parameter that was used in previous releases for reading a MultiProvider sequentially is no longer used.
    Reward If Helpfull,
    Naresh

  • Internal Error: inconsistent ADT attribute

    Hi there,
    I am using Stored Procedure on the Oracle side and return a geometry contains a point.
    and on the java side, I am using
    oracle.sql.STRUCT max_geom = (oracle.sql.STRUCT) outParams.get("max_geom");
    JGeometry geom = JGeometry.load((oracle.sql.STRUCT) outParams.get("max_geom")); -- this line give me Internal Error: inconsistent ADT attribute.
    The java code used to work with my data, and I am loading new data. I don't know if it's related to data or something else. The stored procedure works fine when I run it in toad.
    However, when I put debug statement there the max_geom is not null and it does have something in it.
    I got the same error msg even if I just want to do max_geom.getAttributes().length;
    I can print the value of max_geom.getLength() is 41.
    Please help
    Thanks
    Shawn

    Yes,
    I changed most of the cursor functions to cast(multiset()). Sometimes i divided a big query into two or three queries (when there was cursor nested in a cursor). It was one day work for me. Don't forget to change the tags with ROW to ITEM in your xsl-stylesheets.
    Uwe

  • Alert Log time showing a different time

    Hi,
    Our Oracle 10g database is hosted on HP-UX B.11.31 U ia64 server. Recently after Rebooting the server
    we noticed the time in the alert.log and the time in the server is entirely different.
    when we queried the date in the database and in the server it shows the same time, but the alert.log is giving
    the different time.
    Whether anyone experienced this sort of problem and plz share how you rectified it

    "When you query the time from database say select sysdate from dual, it is taken from system time"
    It is a bit more complicated.
    When you use the BEQueath protocol, the time is taken from the system clock, modified by the TZ variable for your session.
    When you connect using the listener, the time is taken from the listener, modified by the TZ variable for the listener session.
    When you are on RAC, the listener inherits the time from the global services daemon, modified by the TZ variable for the global services daemon.
    I had to investigate this, as Oracle 9i doesn't understand the M3.5-M10:4 syntax I need to make sure the summertime switches on the Europan moment.
    Regards,
    Sybrand Bakker
    Senior Oracle DBA

  • Getting counts and divide by sum in a single Pivot query

    Hi,
    I have a pivot query which gives the counts of all codes. I also have to divide the count with the total in the same query.
    e.g
      col1          col2                   col3
    error_1       05-Jun-2012       parts
    error_1      05_june_2012     parts
    error_1      04_june_2012     consumables
    error_2      04_june_2012     consumables
    error_3      03_june_2012     parts
    .Now the output should have the counts/divided by sum multiplied by 100. Basically, the percentage.
    output will be something like
    error                     June-2012                                 May-2012                              Feb-2012 ....      headers
    error_1                    60%                                          0 %                                         0%
    error_2                    20%                                          0                                             0%
    error_3                    20%                                           0%                                         0%Any suggestions please?
    Thanks,
    Sun

    with
    t1 as
    (select 'error_1' col1,trunc(sysdate) - 1 col2 from dual union all
    select 'error_1',trunc(sysdate) - 1 from dual union all
    select 'error_1',trunc(sysdate) + 30 from dual union all
    select 'error_2',trunc(sysdate) + 31 from dual union all
    select 'error_3',trunc(sysdate) - 2 from dual union all
    select 'error_3',trunc(sysdate) + 30 from dual union all
    select 'error_1',trunc(sysdate) - 3 from dual union all
    select 'error_2',trunc(sysdate) - 2 from dual union all
    select 'error_3',trunc(sysdate) + 30 from dual union all
    select 'error_4',trunc(sysdate) - 6 from dual
    select col1,
           count(case to_char(col2,'mon') when 'jul' then 1 end) one,
           100 * ratio_to_report(count(case to_char(col2,'mon') when 'jul' then 1 end)) over () x,
           count(case to_char(col2,'mon') when 'jun' then 1 end) two,    
           100 * ratio_to_report(count(case to_char(col2,'mon') when 'jun' then 1 end)) over () y
      from t1
    group by col1
    order by col1Regards
    Etbin
    Edited by: Etbin on 8.6.2012 14:15
    used next month to keep english and slovenian 'mon' the same ;)

  • Zero divide error in my query sq01

    Hi Gurus
    I keep getting a 0 divide error in my query, I think it's because some of the invoices have 0.00 dollars amount, t
    For Contribution Margin in sq01 I wrote a formula in Calculation formula
    CONT_MARG / (MAT_PRC-FRGT_PROV + DISC_SURC+FREIGHT ) * 100
      Condition : MAT_PRC-FRGT_PROV <> 0 OR DISC_SURC+FREIGHT <> 0.
    after running the invoice I am getting an error as zero divide in the report
    Any help will be appreciated 
    Thanks in Advanced

    Hi,
    Change your query like below
    define a local variable l_variable.
    l_variable = (MAT_PRC-FRGT_PROV + DISC_SURC+FREIGHT ) * 100 .
    IF l_wariable IS NOT INITIAL.
    CONT_MARG / l_variable.
    ENDIF.
    Regards,
    Atish

  • Zero divide error in my query

    Hi Gurus
    I keep getting a 0 divide error in my query, I think it's because some of the invoices have updated for 0.00 dollars, then we've fixed them and released them to accounting but you know these crap structures, they retain each document history, so have kept the 0.00 values. 
    THis is my calculation, can you see anything obviously wrong with it puleeeese.
    CONT_MARG / (MAT_PRC-FRGT_PROV+ DISC_SURC+FREIGHT ) *100
    thank u in advanced
    Piroz

    Hi,
    I would suggest to calculate the denominator first.
    A = (MAT_PRC-FRGT_PROV+ DISC_SURC+FREIGHT ) * 100
    If A > 0 then perform the other calculation of dividing the value by A.
    This should solve problem.
    Regards,
    Shahu

  • What are the query errors can be rectified using trns code rsrt?

    Hi all,
    Can anyone let me know the sigifiance of trns code rsrt? with examples. Nor can anyone send me a documentation about rsrt describing its functions and significance.
    What are all the errors will be rectified using rsrt ?
    regds
    hari

    hi,
    RSRT : Query monitor to debug and test the queries. U can test IGS(internet Graphical Service) also.RSRT is to scan the query as to how the query gets executed, whether it uses aggregates or cubes, full table scan or uses index, etc.
    You can also change the performance of a query under the 'Properties' tab.
    If you switch the Read Mode to 'A' - 'Query to Read All Data at Once', it can really kill the query performance. Instead of reading data with each navigation, it reads it all before it loads. It will speed up navigation after the report has rendered, but kill the load time.
    The 'Generate Report' button can be used with the report has become corrupt. It will regenerate the report. It hasn't happened many times, but I've had reports that just failed to run when no change has been made. Regenerating the report fixed it.
    Execute + Debug is a lifesaver when you need to trace user exits in your report. It has a lot of neat options
    chk this link..
    http://help.sap.com/saphelp_nw04/helpdata/en/a0/2a183d30805c59e10000000a114084/content.htm
    hope it helps..

  • How to divide resultset of a query in different ref cursors in a package

    Hi Oracle Gurus,
    I need to create a package which counts the no of rows returned by a select query on multiple tables and according to the returned rowcount inputs the resultset in a ref cursor. Procedure will be called by a .NET program and output param refcursor will be assigned to a data reader which will redirect all the data to an Excel file.
    All the above is done. Issue is due to Excel's limit of 64000 rows, if data returned by query is greater than 64K it wont be fit in 1 Excel sheet. So, in order to overcome this limit I need to do some looping in Oracle package which keeps on storing the query results (rows<64K) in different ref cursors so that these refcursors as OUT params can be redirected to separate Excel sheets in C# program.
    NOTE : Earlier on I created 2 procedures in the package to fetch rows<64K and another one to fetch rows between 64K and rowcount of the query. My program was calling 2 different procedures to redirect data into 2 diff Excel sheets.
    But this fails when query resultset is even greater than 128000 or more and demands 3-4 or even more Excel sheets to be created.
    Please help.
    Any idea how to do looping in Oracle to accomplish this?

    > So, in order to overcome this limit I need to do some looping in Oracle package which keeps on
    storing the query results (rows<64K) in different ref cursors so that these refcursors as OUT params
    can be redirected to separate Excel sheets in C# program.
    Huh?
    That is saying that "I need to change this road and build it straight through that lake as the road has a curve here".
    It surely is a LOT easier to leave the road as is and simply turn the darn steering wheel in the car?
    Have the .Net data reader keep a row count of rows read from the ref cursor - and when it reached a pre-set max, have the reader do a "control break"[1] and change to a new worksheet as the destination for writing the rows to.
    [1] Google the term if you do not understand this basic concept that was among the very basic program control structures taught back in the 80's.. while I foam at the mouth how today's "wonder kids" turned programmers, that grew up with computers, do not even comprehend the most basic programming logic designs...

  • Plz help me rectify this query

    Hi,
    I am trying to use a OR condition in NOT IN clause, is the SQL statement correct way:
    select name from master_list where ((id not in (select id from deleted_list)) OR (id not in (select id from inactive_list)))
    I there are two tables which contain ids which should be in not in clause.
    Thanks,
    Raja

    Hi,
    Whenever you post fomatted text on this site (and code should always be formatted), type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    What is the problem?
    Are you getting an error message?
    Why not post the error message?
    Are you getting the wrong results?
    Post some sample data, and the results you want to get from that data.
    NOT IN will never be TRUE if the sub-query includes any NULL rows. I can't tell if that's possible with your tables or not..

  • This Query IS giving divide by zero error when executed in sql plus

    UPDATE grn G
    SET g.OPT_WA_FAIR_VAL_A = (SELECT
    ROUND(SUM(NVL(ga.OPT_FAIR_VAL_A, 0) * NVL(gvs.GRN_VEST_OPT_Q, 0)) / SUM(NVL(gvs.GRN_VEST_OPT_Q, 0)), 6)
    FROM
    GRANT_VESTING_SCHEDULE gvs,
    GRANT_ASSUMPTION ga
    WHERE
    gvs.ORG_GRP_I = ga.ORG_GRP_I AND
    gvs.grn_n = ga.grn_n AND
    ga.ORG_GRP_I = g.ORG_GRP_I AND
    ga.GRN_N = g.GRN_N AND
    NVL(ga.GRN_ASMPN_EFF_D, gvs.grn_vest_d) <= gvs.grn_vest_d AND
    NVL(ga.GRN_ASMPN_END_D, gvs.grn_vest_d) >= gvs.grn_vest_d
    WHERE G.ORG_GRP_I =5
    Any suggestions

    hi
    What should be result if divide by zero e.g
    SQL> SELECT * FROM emp;
        EMPNO ENAME        JOB             MGR HIREDATE        SAL      COMM    DEPTNO
         7901 SMITH        CLERK          7902 17-DEC-80         0         0        20
         7499 ALLEN        SALESMAN       7698 20-FEB-81      2100      1800        30
         7521 WARD         SALESMAN       7698 22-FEB-81      2300      2000        30
         7566 JONES        MANAGER        7839 02-APR-81      1000      3000        20
         7654 MARTIN       SALESMAN       7698 28-SEP-81      3200       700        30
         7698 BLAKE        MANAGER        7839 01-MAY-81      1000      3000        30
         7782 CLARK        MANAGER        7839 09-JUN-81      1000      3000        10
         7788 SCOTT        ANALYST        7566 19-APR-87      1000      1900        20
         7839 KING         PRESIDENT           17-NOV-81      1000      1700        10
         7844 TURNER       SALESMAN       7698 08-SEP-81      1800       700        30
         7876 ADAMS        CLERK          7788 23-MAY-87      1000      1300        20
         7900 JAMES        MANAGER        7698 03-DEC-81      1000      3000        30
         7902 FORD         ANALYST        7566 03-DEC-81      1000      2000        20
    13 rows selected.
    SQL> SELECT sal/DECODE(comm,0,1,comm) FROM emp;
    SAL/DECODE(COMM,0,1,COMM)
                            0
                    1.1666667
                         1.15
                    .33333333
                    4.5714286
                    .33333333
                    .33333333
                    .52631579
                    .58823529
                    2.5714286
                    .76923077
                    .33333333
                           .5
    13 rows selected.Khurram

Maybe you are looking for