Q
Problem solve Get help with specific problems with your technologies, process and projects.

Function is nested too deeply

I am trying to run this query and I get an error: "ORA-00935: group function is nested too deeply." Please help me.

I am trying to run this query and I get an error:

SQL> select
  2  * from member m
  3  where m.username IN (select fg.username from filmography fg,
  4  (select f.username,max(count(awards)) from filmography f
  5  group by username,awards
  6  having max(count(awards))
  7  >0));
having max(count(awards))
           *
ERROR at line 6:
ORA-00935: group function is nested too deeply

Please help me.

Okay, the error message is saying that you cannot nest functions like that.

It looks like all you want is the member with the most awards. Here's how I would do this in Oracle:

select username
     , othercolumns
  from member 
 where username in 
      ( select username 
          from ( select username
                   from filmography 
                 group 
                     by username
                 order
                     by count(awards) desc
               ) as t
         where rownum = 1
      ) 

WHERE ROWNUM=1 is used to obtain the row which has the largest COUNT(AWARDS) in the innermost subquery.

This was last published in June 2006

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close