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

Similar Messages

  • 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 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.

  • 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

  • Group function is not allowed here

    Hi,
    I have a problem running the following sql command, i know the error is over the count function, but i don't know how to solve this. Can you please help me solve this.
    ( i would like to select titles that have more than 2 authors.)
    select distinct titles.title_id, titles.title_name, titles.publisher_ID
    from authors, titles, author_titles
    where titles.title_ID= author_titles.title_id
    and author_titles.au_id = authors.au_id and count(authors) > 2
    ORDER BY titles.title_id DESC ;
    thank Yoy

    Sorry i'm new to databases....
    I tried to add the group by function ... but i still get errors
    select distinct titles.title_id, titles.title_name, titles.publisher_ID
    from authors, titles, author_titles
    where titles.title_ID= author_titles.title_id
    and author_titles.au_id = authors.au_id
    group by titles.title_id
    having count(authors.au_id) > 2
    ORDER BY titles.title_id DESC ;
    error
    select distinct titles.title_id, titles.title_name, titles.publisher_ID
    ERROR at line 1:
    ORA-00979: not a GROUP BY expression
    * >>> on titles.title_name

  • Group function is not allowed here - where statement

    I have a select that is basically:
    select a,b,
    sum(c),sum(d),
    sum(c) - sum(d)
    from A
    group by a, b
    I would like to add:
    where sum(c) - sum(d) <> 0
    I know that I can't use the sum function in the where statement.
    Any ideas how I can get around it?
    Thanks.
    Leah

    Hi ,
    for instance ... using the count aggregate function... which is the same as using sum function.....
    SQL> select job , cnt_emp , cnt_sal
      2    from
      3    (
      4      select job, count(empno) cnt_emp, count(sal) cnt_sal
      5        from emp
      6      group by job
      7    )
      8   where cnt_emp- cnt_sal=0
      9  /
    JOB                            CNT_EMP    CNT_SAL
    CLERK                                5          5
    SALESMAN                             5          5
    PRESIDENT                            1          1
    MANAGER                              3          3
    ANALYST                              2          2Greetings....

  • Error: Group Function Is Not Allowed Here

    Post Author: simiora
    CA Forum: WebIntelligence Reporting
    Hi,
    Created a measure in the Universe, which is based on a BO built-in function "PERCENTILE".
    When this measure is in the WebI report, this field is also added to the GROUP BY caluse of the select statement, which will give the above error.
    Is measure defined wrong? How to eliminate a field from the GROUP BY clause. We are using Oracle database and BOXI Rel 2.
    Thanks.

    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

  • 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

  • ALE-IDOC Error -Function module not allowed: ZIDOC_INPUT_MATCLASS

    Hello all,
    I am having a requirement to enhace bd10  to suit for material master.For that i have written a Z-function module to at inbound side.
    Function module has coading for extended segments and z processing code is created for the same.
    The issue is that i am getting error-Function module not allowed: ZIDOC_INPUT_MATCLASS.Please help to resolve the issue.
    Thank you.

    I have checked as per your suggestion in detail the error reported as-
    Function module not allowed: ZIDOC_INPUT_MATCLASS
    Message no. B1252
    Diagnosis
    The function module ZIDOC_INPUT_MATCLASS and the application object type which were determined are not valid for this IDoc.
    Procedure
    1. Please check that the process code in the inbound partner profile is correct.
    2. If this is the case, you should check the ALE inbound methods ALE inbound methods for the process code and see whether the specified function module and application object type are correct.
    3. If this is also the case, then the function module and the application object type are not permitted for the logical message type, message variant, message function and basis type that are contained in the IDoc control record. You should check whether the correct values have been assigned to these fields in the control record. If they do have the correct values, then the assignment to the function module and the application object type needs to be maintained.
    I am done with all the procedure.
    I am currently using-BUS1001006.I really dont know if this is the one for extended idocs and z function module for material master.Please guide me if this is the issue. And i f so please guide right buziness object.
    Thanks.
    Edited by: sanjivrd on Sep 22, 2009 1:27 PM

  • Error while creating Notification: Partner Function is Not Allowed in Partner Determination Profile Q2

    During Notification Creation I get the error --Partner Function is Not Allowed in Partner Determination Profile Q2
    As I enter Purchase Document Number in the transaction QM01 and press Enter. I get the above error and donot go further.
    Can anyone help me here.

    Hello Prashant,
    You are missing some configuration for the partner function;
    Go- to
    SPRO>IMG>QM>Quality Notifications>Notification Creation>Partners>Define partner Determination Procedure>
    Again Select "Define Partner Determination Procedure".
    Select Quality management> Change Partner
    Now Select Q2.
    Compare settings with Partner Determination Procedure on any other client. Also check Partner functions on the same screen.
    Amol.

  • IDOC error 51- Function module not allowed:

    Hi,
    I am getting following error in IDOC inbouond.I verifyed all parameters mentioned in error.
    Issue still not resolved.
    When debugged from WE19 this issue dosnt arise.
    Kindly guide.
    Function module not allowed: ZIDOC_INPUT_MATCLASS
    Message no. B1252
    Diagnosis
    The function module ZIDOC_INPUT_MATCLASS and the application object type BUS1001 which were determined are not valid for this IDoc.
    Procedure
    1. Please check that the process code in the inbound partner profile is correct.
    2. If this is the case, you should check the ALE inbound methods ALE inbound methods for the process code and see whether the specified function module and application object type are correct.
    3. If this is also the case, then the function module and the application object type are not permitted for the logical message type, message variant, message function and basis type that are contained in the IDoc control record. You should check whether the correct values have been assigned to these fields in the control record. If they do have the correct values, then the assignment to the function module and the application object type needs to be maintained.

    Hi,
    Check in WE42, for the process code, you have assigned this function module and given the correct process code in the partner profile.
    Sujay

  • Function module not allowed: IDOC_INPUT_INVOIC_MRM in 4.6C

    Hi All,
    I am working on SAP 4.6C, I am trying to post an idoc through WE19 and using message type INVOIC and basic type - INVOIC02. Also, we are using the process code - INVL which using the function IDOC_INPUT_INVOIC_MRM.
    While trying to post an MM Invoice after entering all the parameters in WE19, the IDoc in status 51.
    Also, the error message states that "Function module not allowed: IDOC_INPUT_INVOIC_MRM". Since it is a standard function module, I donu2019t know how to get to solve the problem.
    Thanks in advance.
    Regards,
    Nagarajan

    Hi Nagaraju ,
    Make Entries in WE57 . To make entries in this Take help of WE42-Inbound process code INVL .If u did not have the entries then it causes  this error .After logging ur entry Check in  table EDIFCT.
    Hope this helps .
    Rgds
    Sree . M

  • IDOC Error - Function module not allowed: IDOC_INPUT_HRMD

    Hello Gurus,
    I have an issue with the IDOC Transfer. I am using the program RSEINB00 to read the file and convert the data into IDOCs with status 64.
    But all my Idocs are getting created with status 51 and the error is getting populated as " Function module not allowed: IDOC_INPUT_HRMD ".
    Please do let me know whats needs to be done for this to be rectified.
    Thanks,
    Naveen.

    You are not using the right process code.
    In partner profile - in message type
    u will see the process code to which a function module is attached,
    for ur message type, this is not the right function module.
    Regards
    Manu

  • FRM-41009:  Function key not allowed.  Press %s for list of valid keys.

    FRM-41009: Function key not allowed. Press %s for list of valid key.
    What is reason for this message, and how can we suppress it. Where should I set the system.message_level to suppress this message.

    The reason is you press a key that cannot be used, e.g. duplicate record cannot be used in enter query mode.
    You cannot suppress this message, even with message_level 25. If you code this for key-duprec, you will still get the message:
    :system.message_level := 25;
    duplicate_record;Forms intercepts the error at a very early stage. Even this didn't suppress the message:
    if :system.mode = 'ENTER-QUERY' then
      null;
    else     
      duplicate_record;
    end if;

  • Function module not allowed: RSAR_DATA_RECEIVED B1 252

    Hi Friends,
    I have a Data load problem when loading hierarchi data loads i.e. 0material,0prod_hier etc.
    I am getting the following error:
    Error when updating Idocs in Business Information Warehouse
    Diagnosis
    Errors have been reported in Business Information Warehouse during IDoc update:
    Function module not allowed: &
    System Response
    Some IDocs have error status.
    Procedure
    Check the IDocs in Business Information Warehouse . You do this using the extraction monitor.
    Error handling:
    How you resolve the errors depends on the error message you get.
    Under Error Analysis:
    Function module not allowed: RSAR_DATA_RECEIVED B1 252.
    We are getting this problem after refreshing the R/3 source system with production R/3 system.
    the loads went fine before the refresh.
    Data load is taking long time and finally getting failed without pulling any data into BW.
    Looking for valuable suggessions.
    Thanks in advance.
    Laxman

    Cannot load Hierarchies after refresh
    More information in SAP Note 216671.

Maybe you are looking for

  • Unable to change make a down payment using Purchase order

    Hello Experts, I created a purchase order and used that purchase order in f-47 and f-48 (created down payment for the P.O). When i tried to execute the good receipt i encountered an error that said profit center not mentioned in line item 001. I unde

  • East West Keyswitches off by 1 octave in Logic Pro X

    I am using East West Symphonic Orchestra Platinum Plus, Play, and Logic Pro X. The keyswitch notes indicated in the East West manual are one octave lower than the notes that actually trigger the articulations in Logic Pro. For example, the solo violi

  • Dual booting Solaris 10 with Vista

    I got Compaq 3702 with Win Vista - It was a pain for 2 months to installl Solaris - Every time I would Install Solaris - Grub will show Windows but on booting gives messages winload.exe missing or corrupt. Then I found out QTParted - system utility (

  • For a READ TABLE how to build a dynamic WITH KEY condition?

    Hi All, I have a Z table with 6 fields. The first field is the Plant and is the key field. This field can be matched with the field from selection screen. Now I have 4 character fields which can contain various values. Now I have another field at the

  • Just got a Late 2012 iMac 27 inch - recovery issues

    Just got a brand new iMac Late 2012 27 inch model (CPU: 3.4, 1GB GPU, 8GB RAM, 1TB Fusion, 10.8.3). Couple of questions: I tried Command R to get into recovery mode to see if it is working. It is not working at all. I then tried pressing the Option b