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: Using a MIN with a COUNT

Re: Using a MIN with a COUNT

From: Lee Kyoung Rok <tunnel_at_hananet.net>
Date: Wed, 24 Nov 1999 02:57:55 +0900
Message-ID: <JBA_3.594$sI3.22534@news.hananet.net>

Reza <reza_at_digital-dispatch.co.uk>ÀÌ(°¡) ¾Æ·¡ ¸Þ½ÃÁö¸¦ news:943372230.7643.0.nnrp-04.d4f07aaa_at_news.demon.co.uk¿¡ °Ô½ÃÇÏ¿´½À´Ï´Ù.
> Do you mean something like
> SELECT COUNT(r1.nbDesks), nbDesks
>
> FROM rooms r1
> where rownum=1
> GROUP BY (nbDesks)
> ORDER BY 1 ASC;
>
> martinl <laflamme_at_iname.com> wrote in message
> news:C_x_3.1088$ym.59835_at_wagner.videotron.net...
> > Greetings to all,
> >
> > I have a small question regarding the combined use of the MIN and
> COUNT
> > set functions. I have a querry which looks like this:
> >
> > SELECT COUNT(nbDesks), nbDesks
> > FROM rooms
> > GROUP BY (nbDesks)
> > ORDER BY 1;
> >
> > This will return the following results:
> >
> > COUNT(NBDESKS) NBDESKS
> > -------------- --------------------
> > 2 d2
> > 3 d1
> > 3 d4
> > 4 d3
> >
> > Now, using the COUNT(nbDesks) column as a referrence, I would like
to
> > retrieve only the min value of this table, i.e the first line. My
> > question is: is there any way to use the MIN function with the COUNT
> > function to achieve this? As a first try, I attempted to combine them
in
> > the following
> > way:
> >
> > SELECT MIN(COUNT(nbDesks)), nbDesks
> > FROM rooms
> > GROUP BY (nbDesks)
> > ORDER BY 1;
> >
> > But that didn't work. Anybody has an idea? I know I could use a
> cursor
> > to retrieve the first row but I was wondering if there was a more direct
> way
> > to do this.
> >
> > Thanks a lot,
> > Martin
> >
> >
>
>

If there are two or more min values??? Received on Tue Nov 23 1999 - 11:57:55 CST

Original text of this message

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