If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > ORA-00937 error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-04, 04:14
bkm_75 bkm_75 is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
Question ORA-00937 error

I want to lis the dept with the smalles cumulative salary. I tried the foll query in Oracle

Select deptno, min(sum(sal))
from emp
group by deptno;

I get the foll error message

ORA-00937 error: Not a single group group function

What is wrong here? Please help!
Reply With Quote
  #2 (permalink)  
Old 12-10-04, 06:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
i love that error number!!

what is wrong is that you cannot nest aggregate functions like that

i don't do oracle but i think the answer is something like:
Code:
select dept
     , sumsal as minsumsal
  from (select dept
             , sum(sal) as sumsal)
          from emp
        group
            by dept
        order
            by sum(sal) asc)
 where rownum=1
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On