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 -> Re: Simple SQL question...

Re: Simple SQL question...

From: <cyberchik7028_at_my-dejanews.com>
Date: Mon, 03 May 1999 20:14:08 GMT
Message-ID: <7gl02c$irb$1@nnrp1.dejanews.com>


Ok im no pro but i think this *might* fix your problem

SELECT
deptno,
max(sum(sal)) Salary
FROM
emp
GROUP BY deptno;

now you should have two columns, one called deptno and one called Salary grouped by deptno

In article <7gkm35$9gf$1_at_nnrp1.dejanews.com>,   notronrj_at_my-dejanews.com wrote:
> 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
>

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

Original text of this message

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