Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple Query [Q]
Kan Chun Kin (CE) wrote:
>
> hi,
>
> how can i find the deptno that contains most staff and the number
> of staff in that dept from the following relation by a single query
> in sqlplus ?
> snip
Hello,
try :
select deptno,count(*) from emp group by deptno having count(*) in (select max(count(*)) from emp group by deptno);
This SQL will give you the above result
Good luck
Detlev
-- Detlev Goebel detlev.goebel_at_gzs.de ********************Received on Wed May 14 1997 - 00:00:00 CDT