ORA-00907

Hello
When executing a query, I get an error in the next part of the query


(case
When mas_store_item_conversion.formula = 1
then truncate (((store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1) store_tender_comm_bid_t.mdq_value), 0)
else (store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1)
END)

(case store_po_detail.other_taxes > 0, the value true, then another store_po_detail.other_taxes '-' end) as other_taxes,
*
ERROR on line 35:

ORA-00907: lack of right parenthesis


thanx

Hello

I doubt that the truncate function used in the case, try to replace below

case
when mas_store_item_conversion.formula = 1
then (store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1)/store_tender_comm_bid_t.mdq_value
else (store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1)
END,

Instead of

(case
when mas_store_item_conversion.formula = 1
then truncate(((store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1)/store_tender_comm_bid_t.mdq_value),0)
else (store_tender_proposal.tender_qty * mas_store_item_conversion.conversion_factor1)
END),

Thank you
Ajay more
http://www.moreajays.com

Tags: Database

Similar Questions

  • ORA-00907: lack of right parenthesis

    Hi all

    on 11.2.0.4 on Win 2008

    When executing:

    Select creele, TRUNC ((creele, 'DD')) of loans;

    I get:

    ORA-00907: missing a closing parenthesis (on column 28).

    Any idea?

    Let's see creele format:

    Select creele loans;

    CREELE

    --------

    10/11/14

    21/10/14

    Thank you.

    Can you tell me please why column A and B have different results:

    Select trunc (AVG (trunc(rendule,'DD')-trunc(creele+1,'DD')), 2) A.

    TRUNC (AVG (trunc(rendule,'DD')-trunc(creele,'DD') + 1), (2) B

    details, loans

    WHERE details.emprunt = emprunts.numero

    and borrowing. NUMBER = dΘtails. LOAN

    AND details.rendule is not null

    GROUP Member;

    Because you say to do different things. Suppose that there is just a line in your table, with a rendule of 30/04/2015 and a creele from 20/04/2015.

    A = 30/04/2015 - (20/04/2015 + 1) = 30/04/2015 - 21/04/2015 = 9

    B = 30/04/2015-4/20/2015 + 1 = 10 + 1 = 11

    If you want to arithmetic operations to be performed in a particular order, it is best to use parentheses to make the order without ambiguity. This would return the same value as the A (if that's what you want):

    TRUNC (AVG (trunc(rendule,'DD') - (TRUNC(creele,'DD') + 1)), 2).

  • ORA-00907 - "lack the right parenthesis.

    Hello

    I am trying to create a procedure to add table scores each month. This is my code:

    create or replace procedure add_partitions

    as

    v_partition all_tab_partitions.partition_name%type;

    v_limit varchar2 (50);

    LONG v_sql;

    Start

    Select to_char (trunc (add_months(sysdate,1), 'MM'), 'Mon_YYYY')

    in v_partition

    Double; -napr. 072014

    Select to_char (trunc (add_months(sysdate,2), 'MM'), 'DD-MM-YYYY')

    in v_limit

    Double; -napr. 08/01/2014

    v_sql: = ' ALTER TABLE CENTRUMADMIN. AUD$ _BACKUP ADD PARTITION '. v_partition | «VALUES LESS THAN (' |)» v_limit | ') tablespace BACKUP_AUDIT';

    immediately run v_sql;

    end;

    /

    The procedure is compiled without errors, but when I run it I get this error:

    ORA-00907 - "lack the right parenthesis.

    After some tests, I am sure that this problem is here: VALUES LESS THAN (' | v_limit |) (')... but I'cant understand whats wrong

    Any ideas? Thanks in advance

    Honza

    Hi Mika,

    Try

    VALUES LESS THAN ("' | v_limit |) (') - three times - 2 gives you a ' in your statement - the 3rd chain delimited

    concerning
    Kay

  • "Order By" in Exists / condition not exist cause ORA-00907 in Apex4.1.1

    Hi guys,.
    We have just improved Apex 3.2.1 to 4.1.1. on Oracle DB V11.2.0.1, while testing the apps in the apex, I encountered this problem.

    When I have a page of the process with a defined condition.
    What Type of Condition is Exists (SQL query returns at least one row) or it does not exist (SQL query returns no line) and the Expression 1 is a query with an "Order By" clause, for example
    SELECT 123 DOUBLE
    ORDER BY 1

    When the process starts, Apex 3.2.1 assess the State and run the process very well, but the Apex 4.1.1 would throw an error: ORA-00907: lack the right parenthesis

    I understand that as an order of the clause in a condition Exists or it does not exist is not necessary and agree that they shouldn't be there in the first place.
    But unfortunately I'm dealing with other codes to developers, and these conditions were coded like that, probably from copy - paste the codes.

    Saying that, I also think that an upgrade of the Apex should not stop anything that works in previous versions without warning or provide a workaround solution, right?

    I don't know if this affects other types of artifacts that may have a condition by their Summit when upgraded to 3.2.1 e.g. areas, Items, calculations, Validations etc.
    Does anyone else get this behavior? and there at - it an easy way to fix these?
    Ideally I won't go through all the processes (and some other artifacts might be affected too) in all applications in all areas of work to verify the condition type and manually remove the "Order By" clause.

    Thank you for advising them

    Just did some tests more

    'Calculation', 'Validation', 'Process' and 'Branches' have the same problem, 3.2.1 takes 'Order By' fine condition Exists/Not Exists, but 4.1.1 throws the error message.

    "The regions", "Buttons", "Items" have the constant behavior - 3.2.1 both 4.1.1 throw error ORA-00907: lack the closing parenthesis, what page is rendered.

    Published by: Danny on 04/25/2012 20:07

    Hey Danny,

    It's interesting. I just had a peek at what happens when you use an EXISTS or NOT EXISTS condition type. The following SQL statement final will be generated with your example above. You can also see that if you run your application in debug mode.

    select count(*) from sys.dual where exists (select 123 from dual order by 1)
    

    The execution of this statement within SQL * Plus will also see the error ORA-00907. It seems that the SQL parser does not have an order by clause in a clause EXIST.

    I wonder why this should have worked in previous versions, but I can only suspect that in the past we can just running

    select 123 from dual order by 1
    

    which may be a little slower, because with the new engine EXISTS SQL statement may stop treatment earlier if it finds a record.
    We try to be backwards compatible, as much as possible, but I doubt that we will change the way it was before due to the alteration of performance would be faced with 99.9% of our customers.

    Possible workaround: you might be able to use the new "search request" to analyze your application "to" fix for all the shots where the attribute name is "Expression 1".

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • ORA-00907: lack the right parenthesis when using Group by clause with xmlagg

    I have the following query and I am getting ORA-00907 error when I use the clause with the xmlagg function group.
    select xmlelement("Mitigation",
                    xmlelement("m_szMethodName",tm.DisplayName),
                    xmlelement("SubstanceInterferenceProtocolList",
                                (select xmlagg(xmlelement("MitigationProtocol",
                                        xmlelement("m_szMethodName",tm.DisplayName),
                                        xmlelement("m_szInterferenceProtocolName",tmp.protocol_name),
                                        xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code),
                                        xmlelement("m_ProtocolParameters",
                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                xmlelement("m_Consumables",
                                                    xmlelement("Consumable",
                                                        xmlelement("m_szConsumId", xrl.rgnt_pack_name),
                                                        xmlelement("m_szProductCode",xrl.pack_prod_code),
                                                        xmlelement("m_nVolume",tmp.fluid_vol),
                                                        xmlelement("m_szProtocolStep",xps.protocol_step_name))),
                                                    xmlelement("m_ProtParamList",
                                                        xmlagg(
                                                        xmlelement("ParameterValues",
                                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                            xmlelement("m_Time",xpsd.parameter_ntime_value))
                                                        group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)
                    )))
                    order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep )
                    from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl,
                    xpr_protocol_settings xps, xpr_protocol_settings_default xpsd
                    where tmp.ccd_test_id = tm.ccd_test_id
                    and tmp.ccd_test_id = xrl.ccd_test_id
                    and tmp.pack_prod_code = xrl.pack_prod_code
                    and tmp.intf_type = 1
                    and xps.protocol_name = xpsd.protocol_name
                    and xps.protocol_step_name = xpsd.protocol_step_name
                    and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist
                    and xps.protocol_name =  tmp.PROTOCOL_NAME
                    )))
    from XPtoXPRTdef_defn_mapping tm
    where tm.DisplayName = 'SYPH'
    If I remove the clause xmlagg and the group by clause, the query works well and not give me the result.
    But in this code XML, the output format is incorrect for my application.

    Could someone help out here?

    Now my problem is that this unique coating is more than 32767 characters and utl_file can write 32767 bytes per line.
    Someone deal with this?

    Serialize the output as CLOB and DBMS_XSLPROCESSOR.clob2file procedure used to write to a file:

    DECLARE
      xml_output CLOB;
    BEGIN
      SELECT XMLElement("Department",
               XMLAgg(
                 XMLElement("Employee",e.job_id||' '||e.last_name)
                 ORDER BY e.last_name
               )
             ).getClobVal() AS "Dept_list"
      INTO xml_output
      FROM hr.employees e
      WHERE e.department_id = 30 OR e.department_id = 40;
    
      DBMS_XSLPROCESSOR.clob2file(xml_output, 'XML_DIR', 'test.xml');
    END;
    /
    
  • ORA-00907 is missing a closing parenthesis in the value

    Hi all

    I am writing code for a table, the value type, but is ORA-00907 missing right parenthesis at the opening of the LOV in the window to submit competing demand.
    The internal code of the defined value is as follows:

    Table:_ gl_ledgers_public_all_v gl, gl_ledgers lg, gl_ledger_configurations lc

    Columns in the table:_
    Value: gl.name
    ID: gl.ledger_id

    Où :_
    WHERE gl.ledger_id = lg.ledger_id 
          AND lg.configuration_id = lc.configuration_id 
          AND :$FLEX$.FND_MO_REPORTING_LEVEL='1000'
    UNION ALL
    SELECT name, organization_id
       FROM hr_operating_units
       WHERE :$FLEX$.FND_MO_REPORTING_LEVEL='3000'
    Where FND_MO_REPORTING_LEVEL is a value which returns Char and is used by a previous setting.

    I looked around for the triggers of this error (misuse apostrophes, questions of subquery...) but nothing in my case. Can someone check to see what could be the cause of this error? Thanks in advance.

    Oops!
    It looks like we can't use UNION / GROUP BY / SEEN in value sets' where clause article, as it implecitly by adding parentheses.
    Of http://docs.oracle.com/cd/A60725_05/pdf/flex.pdf

    Special treatment for WHERE the Clauses
    Behind the scenes, the flexfield adds one and... clause in the WHERE clause that you set for your table validated set of values.
    If your WHERE clause contains a RC, then the seal in the annex AND clause may not apply to your WHERE clause integer (without the brackets).
    and could not get the desired result.
    Then, flexfields put implicitly parentheses around your WHERE clause.

    http://docs.Oracle.com/CD/A60725_05/HTML/comnls/us/FND/fndffm03.htm

    Of http://docs.oracle.com/cd/E18727_01/doc.121/e12892/T354897T361276.htm
    You can create a view with the UNION and use it in the set of values.
    (Or) you will need to have an internal selection in the field of the table itself.

    By
    VAMSi

  • Using DBMS_METADATA. GET_DDL get error: ORA-00907: lack the right parenthesis

    Hello

    I try to extract the schema DDL to a base (10.2.0.4.0 - 64-bit Enterprise Edition on Solaris 10). I ran the query below and get an ORA-00907: parenthesis right absent error.

    SELECT DBMS_METADATA. GET_DDL (REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN ('TABLE_PARTITION', "INDEX_PARTITION", "LOB");

    This is the output when executing the above in the sqlplus worksheet

    Select DBMS_METADATA. GET_DDL (REPLACE (object_type, ", '_') as object_type, object_name) FROM user_objects if object_type in ('TABLE_PARTITION',"INDEX_PARTITION","LOB")
    *
    ERROR on line 1:
    ORA-00907: lack of right parenthesis

    remove the where the clause gives the following:

    Select DBMS_METADATA. GET_DDL (REPLACE (object_type, ", '_') as object_type, object_name) FROM user_objects
    *
    ERROR on line 1:
    ORA-00907: lack of right parenthesis

    Pointers would be welcome. I know I could get the DDL using exp/imp, but I'd like to understand why I get the error of missing parenthesis.

    see you soon,

    Ewan

    SELECT DBMS_METADATA. GET_DDL (REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN

    You don't need an alias here. Getting rid of the "as long as object_type' and it should work.

  • between problem: ora-00907

    Dear professionals,
    I'm trying to get some results with the following code:
    V_Default_Where := 'kadi_pk between to_date('||to_char(:kadipk_par1,'dd.mm.yyyy')||',''dd.mm.yyyy'') and to_date('||to_char(:kadipk_par2,'dd.mm.yyyy')||',''dd.mm.yyyy'')';
    set_block_property('acc_pr_delay',default_where,V_Default_Where);
    The two form fields, kadipk_par1 and kadipk_par1 are date (exact) format.

    During the execution of the query, I received the following error: ORA-00907: lack the right parenthesis
    When press: CTRL + SHIFT + E, I see this:
    SELECT ssorgj_pr, broj_pr, company
    Of acc_pr_delay
    WHERE the kadi_pk between to_date(*01.01.2010*,'dd.mm.yyyy') and to_date(*21.01.2010*,'dd.mm.yyyy')

    to obtain accurate data, it must be: WHERE kadi_pk between to_date(*'01.01.2010'*,'dd.mm.yyyy') and to_date(*'21.01.2010'*,'dd.mm.yyyy')
    (both dates must be in ")
    How to get there?

    Thank you very much in advance...
    Adnan

    Adnan,

    Change the statement of

    V_Default_Where := 'kadi_pk between to_date('||to_char(:kadipk_par1,'dd.mm.yyyy')||',''dd.mm.yyyy'') and to_date('||to_char(:kadipk_par2,'dd.mm.yyyy')||',''dd.mm.yyyy'')';
    

    TO

    V_Default_Where := 'kadi_pk between to_date(''' || to_char(:kadipk_par1, 'dd.mm.yyyy') || ''', ''dd.mm.yyyy'') and to_date(''' || to_char(:kadipk_par2, 'dd.mm.yyyy') || ''', ''dd.mm.yyyy'')';
    

    Kind regards

    Manu.

    If my answer or the answer to another person has been useful or appropriate, please mark accordingly

  • materialized view ora-00907, although sql query works well

    Hello

    It seems to be a bug with db oracle 10.2.0.1 and his prod. env, I can't apply the patch quickly, can anyone give me a tip

    CREATE THE MV_TEN MATERIALIZED VIEW
    BUILDING THE INDEX REFRESH IMMEDIATE TO COMPLETE ON DEMAND HELP
    AS
    SELECT ten.tcy_refno AS TENANCY_REF,
    Rev.rac_accno AS REV_ACC_NO,
    Rev.rac_last_aba_date AS LAST_ABA_DATE,
    Rev.rac_last_aba_balance AS LAST_ABA_BALANCE,
    AAA.aca_status AS ARREARS_STATUS,
    AAA.aca_ara_code AS ARREARS_ACTION_CODE,
    AAA.aca_effective_date AS EFFECTIVE_DATE,
    AAA.aca_balance AS ACCOUNT_BALANCE,
    ARA.ara_description AS ARREARS_DESCRIPTION,
    NPA.nop_text
    OF REVENUE@remotedb rev.
    Ten TENANCT@remotedb.
    ACCOUNT_ARREARS_ACTIONS@remotedb aaa
    LEFT OUTER JOIN ARREARS_ACTIONS@remotedb ara
    ON aaa.aca_ara_code = ara.ara_code
    LEFT OUTER JOIN NOTEPADS@remotedb IR
    ON aaa.aca_reusable_refno = npa.nop_reusable_refno
    WHERE ten.tcy_refno = rev.rac_tcy_refno
    AND rev.rac_end_date IS NULL
    AND rev.rac_accno = aaa.aca_rac_accno
    AND aaa.aca_status! = "DEL".
    AND npa.nop_current_ind = 'Y ';

    ORA-00907: missing just paraenthesis


    Thank you

    See

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:4226402560732847:P11_QUESTION_ID:6585774577187

  • ORA-00907 MISSING RIGHT PARENTHESIS

    Hi all

    The query

    FLASHBACK TABLE schema.table_name to TIMESTAMP (January 18, 2008 18:55:58 ',' MON-DD-YYYY HH24:MI:SS');


    gives me error

    ORA-00907 MISSING RIGHT PARENTHESIS

    WHAT AM I MISSING HERE?


    kAI

    WHAT AM I MISSING HERE?

    Try

    flashback table schema.table_name to timestamp( to_timestamp('18-JAN-2008 18:55:58','DD-MON-YYYY HH24:MI:SS'));
    
  • ERROR: in the first line ORA-00907 missing paréntesis

    He comes to the table I was trying to create:

    create table (Department)
    dept_id integer not null,
    dept_name varchar2 (20) not null,
    key constraint primary pk_departement (dept_id));

    The response was:

    ERROR at the forefront
    ORA-00907 closing missing paréntesis

    Does someone of you can give me a help?

    Thank you very much

    Nicolò

    Using the exact code to Sean:

    SQL> create table department (
      2  dept_id integer not null,
      3  dept_name varchar2(20) not null,
      4  constraint pk_departement primary key (dept_id));
    
    Table created.
    

    What tool do you use? You can paste the session?

  • error: ora-00907 lack the right parenthesis

    Hello


    I don't know where I am doing wrong, please help me


    update of tmp_data_mins p

    SET p.DISPLAY_VOLUME = ((select display_volume from tmp_data_mins

    where RULE_APPLIED =' rule 2: three consecutive time intervals are

    missing with the period ') q

    where (to_char (p.DAYASDATE,'DD/MM/YYYY HH24')) =

    (to_char (q.DAYASDATE,'DD/MM/YYYY HH24'))

    AND p.HOURASNUMBER = q.HOURSNUMBER);


    Thanks in advance

    Your syntax is disabled, you try to make a mixture of subquery and join that is not valid.  It should be something more like:

    update of tmp_data_mins p

    SET p.DISPLAY_VOLUME = (select display_volume

    of tmp_data_mins q

    where q.RULE_APPLIED =' rule 2: three consecutive time intervals are missing the period ' and

    trunc (p.DAYASDATE, 'hh24') = trunc (q.DAYASDATE, 'hh24')

    AND p.HOURASNUMBER = q.HOURSNUMBER)

    where exists (select display_volume

    of tmp_data_mins q

    where q.RULE_APPLIED =' rule 2: three consecutive time intervals are missing the period ' and

    trunc (p.DAYASDATE, 'hh24') = trunc (q.DAYASDATE, 'hh24')

    AND p.HOURASNUMBER = q.HOURSNUMBER);

    I'm not ethat you really need the trunc applied to dates, but it is equivalent to your expression to_char, and it is generally much safer to compare dates in dates rather than convert a date to a string and compare those.

    Also note that, as wrote your query and mine updates all rows in the parameter tmp_data_mins display_volume table to null for rows that do not match the subquery.  You would (probably) need to add another predicate in the outer query the identifu only the lines that you want to update, and there are predicate using the same query in the clause set would be a likely candidate.

    That said, I don't understand what you're trying to accomplish with this update because you're updating at the same table you are querying of.  As said by Frank, a few examples of data and an explanation of what you're trying to accomplish would be useful.

    John

    After seeing just this thread https://community.oracle.com/thread/3560425 I think I understand what you're trying to do and changed the query above (I think) do the update that you want, and it seems that you have the trunc applied to dates.

    Post edited by: John Spencer

  • [Error] Run (): ORA-00907: lack the right parenthesis

    Hello world

    help out me fom this problem

    SELECT (SELECT LPAD (s.b_borough_no, 2, 0) |) '/' || LPAD (s.site_no, 6, '0')

    OF s app.sites@sfm

    ID WHERE = sit_id)

    as full_id,

    TRS.*,

    VP. FINPERID,

    VP. FINPERCH

    OF tr_review_schedules trs, TIMINGREVIEW. VP VW_FINANCIAL_PERIODS

    WHERE the trs.sched_closeout_date BETWEEN (vp. PERSTARTDATE = TO_DATE (APRIL 1, 2011 00:00:00 "," MM/DD/YYYY HH24:MI:SS')))

    AND (vp. PERENDDATE = TO_DATE (APRIL 30, 2011 00:00:00 "," MM/DD/YYYY HH24:MI:SS')))

    AND trs.trd_id IS NOT NULL

    AND trs.reportable = 'Y '.

    ORDER BY 1;

    Your problem is in him between predicate.  The format of is:

    column between value1 and value2

    I don't quite know what you're trying to do with the columns perstartdate and perenddate, but maybe something more like:

    Select (select lpad (s.b_borough_no, 2, 0) |) '/' || LPAD (s.site_no, 6, '0')

    of app.sites@sfm s

    where id = sit_id) as full_id,

    TRS.*, vp.finperid, vp.finperch

    of tr_review_schedules trs, timingreview.vw_financial_periods vp

    where trs.sched_closeout_date between vp.perstartdate and vp.perenddate and

    TRS.trd_id is not null and

    TRS.reportable = 'Y' and

    VP.perstartdate = to_date (April 1, 2011 00:00:00 ',' dd/mm/yyyy hh24:mi:ss') and

    VP.perenddate = to_date (April 30, 2011 00:00:00 ',' hh24:mi:ss' of dd/mm/yyyy)

    order by 1;

    However, I am not convinced that this is between a reasonable join between tr_review_schedules and vw_financial_periods.

    John

  • ORA-00907 with subquery

    on 10g

    The subquery's auto works, she returns to customer_id duplicate. When can I try to feed those in the IN clause, I get an error about a missing parenthesis, but I don't see missing, any ideas?

    The sub and the containing declaration refer to the Table_A even.


    Select a.CUSTOMER_ID, a.STORE, a.CONNECT, a.DATE_STAMP

    FROM TABLE_A a

    WHERE a.CUSTOMER_ID IN (select CUSTOMER_ID from TABLE_A group by CUSTOMER_ID HAVING count (CUSTOMER_ID) > 1 Order By CUSTOMER_ID);

    Take off the "order by clause.

    select a.customer_id, a.store, a.connect, a.date_stamp
      from table_a a
     where a.customer_id in (select customer_id
                               from table_a
                              group by customer_id
                             having count(customer_id) > 1);
    

    Published by: RPuttagunta on November 9, 2010 13:02

  • Problems...  ORA-00907 otherwise ORA-00937 complex SQL query.

    Hello

    Anyone can solve this query? or tell me what is wrong with him?

    SELECT COUNT (1) Total, RAPP_SERVER, SYSTEM, GOOD, ERROR
    Of
    (
    SELECT tblName.RAPP_SERVER,

    DECODE (SUBSTR (tblName.NOM_SYSTEM, 1, 2), "C0", "CON", "C1", "CON", "CH", "PEPS", "AD", "PEPS", "EA", "PEPS", "OE", "PEPS", "CR", "SYSSERV", 'GS', 'SYSSERV', 'MC', 'SYSSERV', 'EC', 'SYSSERV', a ', 'SYSSERV',)

    ('DB', 'INFO', 'PP', 'INFO', 'ED', 'INFO', 'DO', 'END_SUP', EM ","HIGHER EDUCATION","EP","END_SUP","SE","END_SUP","IF","END_SUP","SR","HIGHER EDUCATION","EI","END_SUP","SG","SAID","ZA","AEL","ZF","AEL","ZI","AEL","IG", ' OTHER ',"LAUGHED", 'OTHER') SYSTEM,
    Sum (case when tblName.ST_CODE = 4 Gold tblName.ST_CODE = 12 Then 1 else null end) AS GOOD,
    Sum (case when tblName.ST_CODE = 4 tblName.ST_CODE = 12 Then NULL else 1 end gold) AS ERROR
    OF GPI01102.tblName
    GROUP BY tblName.RAPP_SERVER, ERROR SYSTEM, GOOD.
    UNION ALL
    SELECT tblName.RAPP_SERVER, DECODE (SUBSTR (NOM_SYSTEM, 1, 3), "DET", "' OTHERS, 'DEU', ' TEACHING)

    HIGHER ',' PRC ',' OTHER ', 'PRO', 'SAYS') SYSTEM.
    Sum (case when tblName.ST_CODE = 4 Gold tblName.ST_CODE = 12 Then 1 else null end) AS GOOD,
    Sum (case when tblName.ST_CODE = 4 tblName.ST_CODE = 12 Then NULL else 1 end gold) AS ERROR
    OF GPI01102.tblName
    GROUP BY tblName.RAPP_SERVER, ERROR SYSTEM, GOOD.
    WHEN FINISHED BETWEEN: P_Start_Date AND: P_End_Date
    )
    RAPP_SERVER GROUP, SYSTEM, GOOD ERROR

    Looking at your original with abbreviated instructions BOX query 2 queries appears to be identical with the exception of the data on the second query restriction.

    SELECT tblName.RAPP_SERVER,
           DECODE(SUBSTR(tblName.NOM_SYSTEM, 1, 2), 'C0', 'CON') SYSTEM,
           SUM(CASE
                 WHEN tblName.ST_CODE = 4 OR tblName.ST_CODE = 12 THEN
                  1
                 ELSE
                  NULL
               END) AS GOOD,
           SUM(CASE
                 WHEN tblName.ST_CODE = 4 OR tblName.ST_CODE = 12 THEN
                  NULL
                 ELSE
                  1
               END) AS ERROR
      FROM GPI01102.tblName
     GROUP BY tblName.RAPP_SERVER, SYSTEM, GOOD, ERROR
    
    UNION ALL
    
    SELECT tblName.RAPP_SERVER,
           DECODE(SUBSTR(NOM_SYSTEM, 1, 3), 'DET', 'AUTRES') SYSTEM,
           SUM(CASE
                 WHEN tblName.ST_CODE = 4 OR tblName.ST_CODE = 12 THEN
                  1
                 ELSE
                  NULL
               END) AS GOOD,
           SUM(CASE
                 WHEN tblName.ST_CODE = 4 OR tblName.ST_CODE = 12 THEN
                  NULL
                 ELSE
                  1
               END) AS ERROR
      FROM GPI01102.tblName
     GROUP BY tblName.RAPP_SERVER, SYSTEM, GOOD, ERROR
     WHERE FINISHED BETWEEN :P_Start_Date AND :P_End_Date
    

    Queries are on the same table twice? If so, can we explain the differences in the results of the 2 queries? You may be able to combine DECODES and use a single query.

Maybe you are looking for