Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Simple SQL question...

Simple SQL question...

From: <notronrj_at_my-dejanews.com>
Date: Mon, 03 May 1999 17:23:54 GMT
Message-ID: <7gkm35$9gf$1@nnrp1.dejanews.com>


Hello,

Got a SQL question. I think it's a simple one, but I am fairly new at SQL. I just took the Intro to SQL from Oracle Education.

I have a table "EMP" that contains employess, dept number and salary and other info.

I want to write a query that returns the dept with the highest combined salary.

So I have done:

select max(sum(sal)) from emp
group by deptno;

And this works great. But I would like to be able to also output the deptno this value is from.

So I tried,

select deptno, max(sum(sal)) from emp
group by deptno;

And I get an error saying that select deptno... is not a group function or something to that effect.

the error is:

ERROR at line 1:
ORA-00937: not a single-group group function

How the heck do I do this?

Thanks for the help,

Newbie

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon May 03 1999 - 12:23:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US