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 Query [Q]

Re: Simple Query [Q]

From: Detlev Goebel <detlev.goebel_at_gzs.de>
Date: 1997/05/14
Message-ID: <3379B67E.1149@gzs.de>#1/1

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

Original text of this message

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