6 Replies Latest reply: Jan 7, 2011 6:00 AM by Hoek RSS

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

    828713
      Hi
      I am trying to create a function that selects avg, max and min prices from a table as shown below:

      create or replace function pricing (mgenre in varchar2)
      return number is
      v_avg_price magazine.unitprice%type;
      v_max_price magazine.unitprice%type;
      v_min_price magazine.unitprice%type;
      begin
      select avg(unitprice) into v_avg_price, max(unitprice) into v_max_price, min(unitprice) into v_min_price
      from magazine
      having genre = mgenre;
      end pricing;

      However, I just get the following error message.

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

      the table magazine has the following columns:
      MAGID
      COMPID
      TITLE
      GENRE
      UNITPRICE
      SUBSCRIPTIONMONTHLY


      any ideas what is going wrong?
      thanks