Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Group by expression + distinct fails with ora 00979

Giedrius S.May 10 2017 — edited May 10 2017

Hello,

I have a question why this cursor fails to open with ora 00979 error (not a group by expression):

   

declare

  cursor c_test(p_prm in varchar2) is

  select 

    decode(p_prm, 1, dummy, 1)

    ,count(distinct dummy)

  from   dual

  group  by

    decode(p_prm, 1, dummy, 1);                

begin

  open c_test(1);

  close c_test;

end;

I found that cursor opens successfuly if you do any of the following:

  • Remove distinct
  • Comment out any of columns
  • instead of p_prm in a cursor use fixed value like "1"

I want to understand why execution fails in this specific case.

Database version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

Thank you

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2017
Added on May 10 2017
14 comments
1,844 views