ORA - 00935, Group function nested to deep

Hi
Suggestions on ho to go round such errors, or if is it any configuration in the database that may be changed.
Extended a view with some lines to aggregate som amounts.
The lines included is as follows:
Sum(Decode(InStr(Upper(rca.lcdescription),'VAL1'),0,0,Nvl(rca.lnprice,0)),
Sum(Decode(InStr(Upper(rca.lcdescription),'VAL2'),0,0,Nvl(rca.lnprice,0)),
Then the ORA - 00935 occured.
The full select looked something like:
SELECT
mg.lcid,
mg.lcdescription,
ro.lcfkestateid,
me.lcestatename,
ro.lcfkbuildid,
mb.lcbuildname,
ro.lcrentobjid,
ro.lcrentobjname,
rot.lcdescription,
ro.lcadr1,
ro.lcadr1,
ro.lcpostcode,
rop.lcpostname,
ro.lnrooms,
rr.lcrenterid,
rr.lcname,
rr.lcrenterid2,
rr.lcaddress1,
rr.lcaddress2,
rr.lcpostcode,
rrp.lcpostname,
rc.lccontractid,
rct.lcdescription,
rc.ldprevailingrentdate,
rc.ldstatusdate,
Sum(Decode(InStr(Upper(rca.lcdescription),'VAL1'),0,0,Nvl(rca.lnprice,0)),
Sum(Decode(InStr(Upper(rca.lcdescription),'VAL2'),0,0,Nvl(rca.lnprice,0)),
Sum(Nvl(mr.lngrossarea,0)) BOA
FROM
tab13 rrp,tab12 rr,tab11 rca,tab10 rct,tab9 rc,tab8 rcs,
tab7 rop,tab6 mr,tab5 mg,tab4 mb,tab3 me,tab2 rot,tab1 ro
WHERE me.lcestateid = ro.lcfkestateid
AND mb.lcestateid = ro.lcfkestateid AND mb.lcbuildid = ro.lcfkbuildid
AND mg.lcgeokey = me.lcgeokey
AND rot.lnrentobjtypkey (+) = ro.lnfkrentobjtype
AND rcs.lnrentobjkey (+) = ro.lnrentobjkey
AND rc.lncontractkey (+) = rcs.lncontractkey
AND rca.lncontractkey (+) = rc.lncontractkey
AND rr.lcrenterid (+) = rc.lcfkrenter
AND mr.lnrentobjkey (+) = ro.lnrentobjkey
AND rop.lcpostcode (+) = ro.lcpostcode
AND rrp.lcpostcode (+) = rr.lcpostcode
AND rct.lncntrtypekey (+) = rc.lnfkconttype
AND rca.lncontractkey (+) = rc.lnfkconttype
GROUP BY
mg.lcid,
mg.lcdescription,
ro.lcfkestateid,
me.lcestatename,
ro.lcfkbuildid,
mb.lcbuildname,
ro.lcrentobjid,
ro.lcrentobjname,
rot.lcdescription,
ro.lcadr1,
ro.lcadr1,
ro.lcpostcode,
rop.lcpostname,
ro.lnrooms,
rr.lcrenterid,
rr.lcname,
rr.lcrenterid2,
rr.lcaddress1,
rr.lcaddress2,
rr.lcpostcode,
rrp.lcpostname,
rc.lccontractid,
rct.lcdescription,
rc.ldprevailingrentdate,
rc.ldstatusdate

Stein,
Is it possible to put the sum(decode statements into another table with the keys you need to join? Then create a view using the newly created sum values table?

Similar Messages

  • I met ORA-00935 group function is nested too deeply Message.

    Hi all,
    I made a table like below,
    ==============================
    CREATE TABLE ser_1m_det (
         time                    TIMESTAMP,
         proto                    NUMBER(3,0),
         port                    NUMBER(5,0),
         pkts                    NUMBER(17,0),
         vol_m                    NUMBER(17,4)
    ====================================
    Then I want to use below SQL
    ====================================
    SELECT proto, port, SUM(pkts) pkts, SUM(vol_m) vol_m
    FROM ser_1m_det
    GROUP BY (proto, port)
    HAVING time < SYSTIMESTAMP AND ROWNUM<10
    ORDER BY SUM(pkts);
    ====================================
    When I execute upper sql, I met this error message;
    ===================================
    ORDER BY SUM(pkts)
    ORA-00935 group function is nested too deeply
    ===================================
    Then I search what this message mean.
    ====================================
    ORA-00935 group function is nested too deeply
    Cause: This is an internal error message not usually issued.
    Action: Contact Oracle Support Services.
    ====================================
    I install Oracle9iAS Infrastructure 9.0.2.0.0 on WIN2000.
    (I am using DBMS in Oracle9iAS @.@)
    -> DBMS version is Oracle9i Enterprise Edition Release 9.0.1.3.1
    Anybody know why I met upper error message?
    Thanks in advance.

    well,
    first you want to group,
    then you want to order,
    and most probably then you are interested in the N top records.
    I had a try on table USER_OBJECTS to make things easier:
    select * from
    (select
    object_type
    ,status
    ,nvl(oi ,0) oi
    ,nvl(doi,0) doi
    from
    ( select
    object_type
    ,status
    ,sum(object_id) oi
    ,sum(data_object_id) doi
    from
    user_objects
    where
    created between sysdate -1000 and sysdate
    group by
    object_type
    ,status
    ) A
    order by
    oi desc
    ) B
    where rownum < 5
    ;

  • ORA-00935:  group function is nested too deeply - SQL Query is correct...

    select s.sname, to_char(sum(t.amount), 'fm$999999.00')
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having (t.year = 1997) and max(sum(t.amount));
    I'm trying to print sales person name who had the highest total sell in 1997. I do not see where did i go wrong in the above query...Isn't nested group function allowed?!
    What about this?
    select s.sname, to_char(sum(t.amount), 'fm$999999.00') as "TOTAL"
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having (t.year = 1997) and sum(t.amount) = (select max(amount) from transactions where year = 1997);
    It should return something, but it does not due lack of data in database. I think the above code is correct. I just need to confirm from you...

    select s.sname, (case when sum(t.amount) > sum(t2.amount)
    then sum(t.amount)
    else sum(t2.amount)
    end) "TOTAL"
    from transactions t, salespeople s
    where t.sid = s.sid
    group by s.sname, t.year
    having t.year = 1997
    union
    select s.sname, sum(t2.amount)
    from transactions t2, salespeople s
    where t2.sid = s.sid
    group by s.sname, t2.year
    having t2.year = 1997;
    Your code looks good, but it does not work in Oracle Developer...
    The above should work isn't it? The inner query gets executed then the outer one so the result i get in

  • ORA-00934: group function is not allowed here

    Hi,
    My requirement is to check oi.quantity is equal to sum of packing_detail. quantity
    by order_number
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd
    where oi.ordered_item_id = pd.ordered_item_id
    and oi.quantity_ordered = sum(pd.quantity)
    and oi.order_number = '29';
    after executing above query I get error
    SQL Error: ORA-00934: group function is not allowed here
    00934. 00000 - "group function is not allowed here"
    Please tell me how to resolve it.
    Thanks in advance
    Sandy

    You have to make use of a subquery;
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd 
    where oi.ordered_item_id = pd.ordered_item_id 
    and oi.quantity_ordered = *(select sum(pd.quantity) from packing_details pd1 group by pd1.ordered_item_id)* 
    and oi.order_number = '29';  This is based on the assumption that ordered_items is the summarize data and packing_details are the line item level data.
    regards,
    Dipankar.

  • PL/SQL: ORA-00934: group function is not allowed here

    Hi,
    I am writing a PL/SQL procedure. The structure is like :
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE Procedure abc
    IS
    v_total_ip_rec number(14);
    v_total_op_rec number(14);
    v_total_rec number(14);
    BEGIN
    SELECT SUM (CASE
    WHEN <condition 1>
    THEN 1
    ELSE 0
    END
    ) into v_total_ip_rec,
    SUM (CASE
    WHEN <condition 2>
    THEN 1
    ELSE 0
    END
    ) into v_total_op_rec,
    SUM (1) into v_total_rec
    FROM A,B
    WHERE A.Col1=B.Col1;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END;
    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: group function is not allowed here"
    Anybody have any idea?
    Any help would be appreciated.
    Thanks.

    Hi Arunkumar ,
    I think you don't need subquery.
    Regards Salim.
    Or.
    SELECT COUNT (CASE
                     WHEN <condition 1>
                        THEN 1
                  END) v_total_ip_rec,
           COUNT (CASE
                     WHEN <condition 2>
                        THEN 1
                  END) v_total_op_rec,
           COUNT (1) v_total_rec
      FROM a, b
    WHERE a.col1 = b.col1

  • ORA-00934: group function is not allowed here Error - On validation screen

    Can anyone help me with this funtion Returning boolean PL/SQL expression
    begin
    select max(sim_trip.finish_time) into finish_time,
          max(sim_trip.start_time) into start_time  from sim_trip
    WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > finish_time)
       then   return true;
    else
    return false;
    end if;
    end;

    Lucy,
    begin
    select max(sim_trip.finish_time) into finish_time,
          max(sim_trip.start_time) into start_time  from sim_trip
    WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > finish_time)
       then   return true;
    else
    return false;
    end if;
    end;Your select statement is wrong. It should be:
    begin
    select max(sim_trip.finish_time),max(sim_trip.start_time)
      into :P500_start_time,:P500_finsh_time 
      from sim_trip
      WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > :P500_finish_time)
       then   return true;
    else
    return false;
    end if;
    end;Robert
    http://apexjscss.blogspot.com

  • PL/SQL equivalent of T-SQL - "group function is not allowed here"

    Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
    SELECT
    CA.AssessmentID,
    (SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
    FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
    AND SnapshotID = 1),
    MAX(CA.PolicyID)
    FROM rptClaimInvoiceLineSnapshot CIL
    INNER JOIN rptClaimAssessmentSnapshot CA
    ON CIL.AssessmentID = CA.AssessmentID
    AND CIL.SnapshotID = CA.SnapshotID
    WHERE CIL.SnapshotID = 1
    GROUP BY CA.AssessmentID
    This works fine in MSSQL but returns the below error in Oracle:
    'ORA-00934: group function is not allowed here'
    If I take out the subquery the query works fine.
    Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
    Thanks in advance!
    Leo

    WITH x AS (SELECT   ca.assessmentid,
                        MAX (ca.policyid) policy_id
               FROM rptclaiminvoicelinesnapshot cil
                    INNER JOIN rptclaimassessmentsnapshot ca
                        ON cil.assessmentid = ca.assessmentid
                       AND cil.snapshotid = ca.snapshotid
               WHERE cil.snapshotid = 1
               GROUP BY ca.assessmentid
    SELECT x.assessment_id,
           x.policy_id,
           productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
    FROM   rptpolicysnapshot, x
    WHERE  policyid = x.policy_id
    AND    snapshotid = 1I think that's in the neighbourhood.

  • Getting Group Function is not Allowed

    Hello All....
    When I run the following in the SQL command screen it works fine... But when I try to use it in APEX to populate page values, it gives me the error...
    ERROR
    1 error has occurred
    ORA-06550: line 25, column 74: PL/SQL: ORA-00934: group function is not allowed here ORA-06550: line 24, column 1: PL/SQL: SQL Statement ignored
    CODE THAT WORKS IN SQL COMMAND SCREEN
    SELECT
    SUM(CASE WHEN SLOT = 'Q' THEN '1' ELSE '0' END) AS C_SLOT,
    SUM(CASE WHEN TEST = 'P' THEN '1' ELSE '0' END) AS C_TEST,
    FROM TBL_REC;
    CODE THAT GIVES ERROR ON APPLICATION EXPRESS PAGE
    SELECT
    SUM(CASE WHEN SLOT = 'Q' THEN '1' ELSE '0' END) INTO :P2_C_SLOT,
    SUM(CASE WHEN TEST = 'P' THEN '1' ELSE '0' END) INTO :P2_C_TEST,
    FROM TBL_REC;
    The colums SLOT and TEST have letter codes, I just want it to count just when it matches a certain letter. In the SQL Command Screen, it is returning one row, with the counts, everything is fine. It is only a problem when I try to use it anywere on a page in Application Express.
    The full version has about 20 lines that are all sum lines, but I can not even get the 2 line ver above to work.
    Any thoughts?

    This will work .. the into clause goes after the select columns ... into var1 ,var2 etc ..
    SELECT SUM(CASE
                 WHEN SLOT = 'Q' THEN
                  '1'
                 ELSE
                  '0'
               END),
           SUM(CASE
                 WHEN TEST = 'P' THEN
                  '1'
                 ELSE
                  '0'
               END)
      INTO :P2_C_SLOT, :P2_C_TEST,
      FROM TBL_REC;SS

  • Error in nested group function used with column name.

    Hi Team,
    If i used nested group function with column name its not working. Could you please any one suggest me.
    How to use it.
    Regards,
    Venkat.
    Please find Spool ........
    SQL> select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name,CNT;
    select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    ERROR at line 1:
    ORA-00937: not a single-group group function
    SQL> select max(max(CNT)) from(select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    MAX(MAX(CNT))
    605

    Venkat wrote:
    Hi Sayan
    Its giving output like below, but not given maximum CNT.
    SQL> select user_name,max(CNT)from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    USER_NAME MAX(CNT)
    BANES_LERG 6
    VENE_USER 8
    USER3 339
    DBUS 106
    VEL_USER 37
    SYS 597
    6 rows selected.Check it - Re: Error in nested group function used with column name.
    and previous post

  • Nested Group Function without Group By Problem

    Hey everyone,
    I have 3 tables as below:
    TABLES
    ITEM (Item_no, Item_price, desc)
    DeliveryItem (delivery_no, item_no, quantity)
    Delivery (delivery_no, delivery_date)
    SELECT desc, MAX(SUM(quantity)) FROM DeliveryItem, Item, Delivery WHERE Item.item_no = DeliveryItem.item_no AND Delivery.delivery_no = deliveryitem.delivery_no;
    And I'm trying to output description of most delivered item but I got an error like SQL Error: ORA-00978: nested group function without GROUP BY. Could you help me to fix my code?
    Thanx

    Hi,
    DESC is not a good column name; you could get errors if the parser thinks it means DESCending. I used DESCRIPTION instead, below.
    I think the best way is to do the SUM in a sub-query, lkike this:
    WITH     got_r_num     AS
         SELECT       item_no
         ,       SUM (quantity)     AS total_quantity
         ,       RANK () OVER (ORDER BY  SUM (quantity) DESC)     AS r_num
         FROM       deliveryitem
         GROUP BY  item_no
    SELECT     i.description
    ,     r.total_quantity
    FROM     got_r_num     r
    JOIN     item          i     ON     r.item_no     = i.item_no
    WHERE     r.r_num     = 1
    ;If you want to do it without a sub-query:
    SELECT       MIN (i.description) KEEP (DENSE_RANK LAST ORDER BY SUM (di.quantity)
                        AS description
    ,       MAX (SUM (quantity))     AS total_quantity
    FROM       deliveryitem     di
    JOIN       item          i     ON     d1.item_no     = i.tiem_no
    GROUP BY  i.description
    ;If you do nested aggegate functions, then every column in the SELECT clause must be an aggregate applied to either
    (a) another aggregate, or
    (b) one of the GROUP BY expressions.
    That's why you got the ORA-00937 error.
    This second approach will only display one row of output, so If there is a tie for the item with the greatest total_quantity, only one description will be shown. The RANK method will show all items that had the highest total_quantity.
    It looks like the delivery table plays no role in this problem, but it there's some reason for including it, you can join it tpo either query above.
    Of course, unless you post test copies of your tables (CREATE TABLE and INSERT statements) I cn't test anything.
    Edited by: Frank Kulash on Nov 6, 2010 10:57 AM

  • ORA-00978  without group function

    I've experienced a strange problem with oracle 11g.
    I've retrieved the oracle exception ORA-00978 even if there was no group function in my query.
    I supposed was a problem in the optimizer so I rebuild the tables statistics, after that the query was execute successfully.
    Does anyone has an idea what the problem is?
    Is possible that a bug exists in the 11g optimizer?
    My oracle version is:
    Oracle Database 11g Enterprise Edition 11.1.0.6.0 64bit Production
    the query i tried is:
    SELECT *
    FROM TBCALENDAR Cal,
    VWCALENDARACTIVITY CA,
    VWSE R,
    TBSCHEDULERPARTITION P,
    TBREGION REG,
    TBRESOURCE RES ,
    TBZIPCITY z
    WHERE Res.id=Cal.RESOURCE_ID
    AND R.RESOURCE_ID=RES.ID
    AND Cal.ACTIVITY_ID=CA.ID
    AND CA.SCHEDULING=1
    AND Cal.SCHEDPARTITION_ID IN
    (select item.PARTITION_ID
    from tbidcprofile prof,
    tbidcpartitem part,
    tbschedpartitem item
    where prof.USERPROFILE_ID=4
    and prof.IDCPARTITION_ID=part.PARTITION_ID
    and part.BUSINESSUNIT_ID=item.BUSINESSUNIT_ID
    and part.REGION_ID=item.REGION_ID )
    AND TRUNC(Cal.START_DT)=trunc(sysdate)
    AND P.ID=Cal.SCHEDPARTITION_ID
    AND REG.ID(+)=Cal.WORKREGION_ID
    AND Z.GEOLOCATION_ID(+)=Cal.HOMEGEOLOC_ID;
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    Thanks
    Renzo

    user479513 wrote:
    VWCALENDARACTIVITY and VWSE are two views, but I can select from them without any problem.
    I've also tried to remove one view at a time an the error occurs only when the query uses both view at the same time.
    What are the views definition ?
    Nicolas.

  • Nested group function

    Hello all,
    How can I use a nested group function in a select statement?
    For example: select sum(count(id), column a, column b from table_name group by???
    Thanks in advance!

    select sum(CNT) column_a, column_b
           from  (select count(id), column_a, column_b from table_name
                            group by column_a, column_b)
    group by column_a, column_b

  • Nested group function without group xmlagg

    I am getting nested group function without group by xmlagg when using the xmlagg function inside another xmlagg function. Find the table structure and sample data here,
    CREATE TABLE "TEST_TABLE"
       ("KEY" NUMBER(20,0),
        "NAME" VARCHAR2(50 ),
        "DESCRIPTION" VARCHAR2(100 )
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (1,'sam','desc1');
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (2,'max','desc2');
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (3,'peter',null);
       Insert into TEST_TABLE (KEY,NAME,DESCRIPTION) values (4,'andrew',null);
    select
            XMLSerialize(document
            xmlelement("root",
             xmlagg(
               xmlelement("emp"          
               , xmlforest(Key as "ID")          
               , xmlforest(name as "ename")
               , xmlelement("Descriptions", 
               xmlagg(
                  xmlforest(description as "Desc")
           ) as clob indent
           ) as t   
          from test_table;Then i removed the xmlagg function from the above select query and used xmlelement instead
      select
            XMLSerialize(document
            xmlelement("root",
             xmlagg(
               xmlelement("emp"          
               , xmlforest(Key as "ID")          
               , xmlforest(name as "ename")
               , xmlelement("Descriptions",            
                  xmlforest(description as "Desc")
           ) as clob indent
           ) as t   
          from test_table;This is working fine, but xml created with empty elements for Descriptions element for key 3 and 4 which has null values. I need don't need Descriptions element in the xml when it has null value. Please help me to resolve this.

    You can do it with a correlated subquery :
    SQL> select xmlserialize(document
      2           xmlelement("root",
      3             xmlagg(
      4               xmlelement("emp"
      5               , xmlforest(
      6                   t.key as "ID"
      7                 , t.name as "ename"
      8                 , (
      9                     select xmlagg(
    10                              xmlelement("Desc", d.description)
    11                              order by d.description -- if necessary
    12                            )
    13                     from test_desc d
    14                     where d.key = t.key
    15                   ) as "Descriptions"
    16                 )
    17               )
    18             )
    19           ) as clob indent
    20         )
    21  from test_table t;
    XMLSERIALIZE(DOCUMENTXMLELEMEN
    <root>
      <emp>
        <ID>1</ID>
        <ename>sam</ename>
        <Descriptions>
          <Desc>desc1_1</Desc>
          <Desc>desc1_2</Desc>
          <Desc>desc1_3</Desc>
        </Descriptions>
      </emp>
      <emp>
        <ID>2</ID>
        <ename>max</ename>
        <Descriptions>
          <Desc>desc2_1</Desc>
          <Desc>desc2_2</Desc>
          <Desc>desc2_3</Desc>
        </Descriptions>
      </emp>
      <emp>
        <ID>3</ID>
        <ename>peter</ename>
      </emp>
      <emp>
        <ID>4</ID>
        <ename>andrew</ename>
      </emp>
    </root>
    Or an OUTER JOIN + GROUP-BY :
    select xmlserialize(document
             xmlelement("root",
               xmlagg(
                 xmlelement("emp"          
                 , xmlforest(
                     t.key as "ID"
                   , t.name as "ename"
                   , xmlagg(
                       xmlforest(d.description as "Desc")
                       order by d.description -- if necessary
                     ) as "Descriptions"
             ) as clob indent
    from test_table t
         left outer join test_desc d on d.key = t.key
    group by t.key
           , t.name
    ;Edited by: odie_63 on 11 juil. 2012 14:54 - added 2nd option

  • ORA-00937:not a single-group group function|ORA-06512:at"schema.procedure n

    ORA-00937:not a single-group group function|ORA-06512:at"schema.procedure name)?
    The details of this procedure are the emp table is used in the emp1 which is shown in line 19
    1 DECLARE
    2 cur_emp sys_refcursor;
    3 TYPE t_tab IS TABLE OF emp%ROWTYPE;
    4 tt t_tab;
    5 cur_emp1 sys_refcursor;
    6 TYPE t1_tab IS TABLE OF emp1%ROWTYPE;
    7 tt1 t1_tab;
    8 BEGIN
    9 OPEN cur_emp FOR
    10 SELECT c1,c2,c3 FROM t1,t2,t3 where t1.c1=t2.c2 and t1.c1=t3.c3;
    11 LOOP
    12 FETCH cur_emp BULK COLLECT INTO tt LIMIT 100000;
    13 EXIT WHEN tt.COUNT=0;
    14 FOR i IN 1..tt.COUNT LOOP
    15 insert in to emp (c1,c2,c3) values (tt(i).c1,tt(i).c2,tt(i).c3;
    16 END LOOP;
    17 END LOOP;
    18 OPEN cur_emp FOR
    19 SELECT c11,c12,c13 FROM emp,t12,t13 where emp.c11=t12.c12 and t11.c11=t13.c13;
    20 LOOP
    21 FETCH cur_emp1 BULK COLLECT INTO tt1 LIMIT 100000;
    22 EXIT WHEN tt1.COUNT=0;
    23 FOR j IN 1..tt1.COUNT LOOP
    24 insert in to emp1 (c11,c12,c13) values (tt1(j).c11,tt1(j).c12,tt1(j).c13;
    25 END LOOP;
    26 END LOOP;
    27 END;
    /

    ORA-00937:not a single-group group function|ORA-06512:at"schema.procedure name)?
    The details of this procedure are the emp table is used in the emp1 which is shown in line 19
    1 DECLARE
    2 cur_emp sys_refcursor;
    3 TYPE t_tab IS TABLE OF emp%ROWTYPE;
    4 tt t_tab;
    5 cur_emp1 sys_refcursor;
    6 TYPE t1_tab IS TABLE OF emp1%ROWTYPE;
    7 tt1 t1_tab;
    8 BEGIN
    9 OPEN cur_emp FOR
    10 SELECT c1,c2,c3 FROM t1,t2,t3 where t1.c1=t2.c2 and t1.c1=t3.c3;
    11 LOOP
    12 FETCH cur_emp BULK COLLECT INTO tt LIMIT 100000;
    13 EXIT WHEN tt.COUNT=0;
    14 FOR i IN 1..tt.COUNT LOOP
    15 insert in to emp (c1,c2,c3) values (tt(i).c1,tt(i).c2,tt(i).c3);
    16 END LOOP;
    17 END LOOP;
    18 OPEN cur_emp FOR
    19 SELECT c11,c12,c13 FROM emp,t12,t13 where emp.c11=t12.c12 and emp.c11=t13.c13;
    20 LOOP
    21 FETCH cur_emp1 BULK COLLECT INTO tt1 LIMIT 100000;
    22 EXIT WHEN tt1.COUNT=0;
    23 FOR j IN 1..tt1.COUNT LOOP
    24 insert in to emp1 (c11,c12,c13) values (tt1(j).c11,tt1(j).c12,tt1(j).c13);
    25 END LOOP;
    26 END LOOP;
    27 END;

  • How to display single row column with nested group function

    SQL> select deptno, Max(sum(sal)) SalSum
    2 from emp
    3 group by deptno;
    select deptno, Max(sum(sal)) SalSum
    ERROR at line 1:
    ORA-00937: not a single-group group function
    Can you please the Help me to get the Max(sum(sal)) with Deptno ......

    select deptno, sum(sal) SalSum
    from emp
    group by deptno;The ablove query will give only one value for SALSUM for a department. So there is no meaning on applying MAX on this for a department..
    What are you trying to achieve?
    This?
    select max(salsum) salsm,max(deptno) keep(dense_rank first order by salsum desc) deptno
    from(
    select deptno, sum(sal) SalSum
    from emp
    group by deptno);Edited by: jeneesh on Sep 4, 2012 6:00 PM

Maybe you are looking for

  • MDM Custom attributes

    Hi gurus, I'm working with SRM-MDM Catalog 1.0 I'm facing this problem. I have imported some item with custom attributes (MDM Import Manager), i have mapped fields and values. In MDM Data Manager items are present but the custom atributes are not pre

  • Difference between user_tab_columns and all_tab_columns

    Hi, Can anybody please let me know what are the differeneces between user_tab_columns and all_tab_columns. Thank you.

  • Invoking a WLI 9.2 business process from JSF Controller class

    I want to call a WLI business process from a java class, which will run in the same JVM as the WLI. I have read that JPD Proxy can be used for this purpose. I am concerned with the overhead of RMI calls. Any insight into this would be helpful .

  • Script Needed to work with "Save for Web" Tool

    I am looking to compress the JPG image files using the Save for Web tool within Photoshop CS2. As you know, this tool yields better results in image quality and file size than the standard Photoshop Save As command. To this end, I would like to batch

  • OAM11g Authentication - Disabled User

    Hi, In OAM 11g, i am able to successfully authenticate using disabled user account. How to prevent this in OAM11g. I have configured OAM to authenticate against Active Directory. The user account is disabled in Active Directory. Even then if the prot