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: Reza <reza_at_digital-dispatch.co.uk>
Date: Tue, 23 Nov 1999 15:49:34 -0000
Message-ID: <943372230.7643.0.nnrp-04.d4f07aaa@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
>
>
Received on Tue Nov 23 1999 - 09:49:34 CST

Original text of this message

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