Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: a select within a count ??

Re: a select within a count ??

From: Chuck <chuckh_at_softhome.net>
Date: 1 Jul 2003 13:27:35 GMT
Message-ID: <Xns93AB60377BC40chuckhsofthomenet@130.133.1.4>


avanrossem_at_hotmail.com (Andre) wrote in news:4d32d1be.0307010018.44650517 @posting.google.com:

> Hello all,
>
> I have a query, but it's not working.
>
> Can someone help me:
>
> select count(*), count(select distinct My_id from Anytable where My_id
> < 1000) from Anytable;
>
> In other words I want to execute a subquery within a count-statement.
> Is it possible ???
>
> Thx!,
> Andre

Looks like you are trying to get a total record count, and a count of only those where my_id < 1000. Try this...

select
  count(*)
, sum(case when my_id < 1000 then 1 else 0 end) from
  anytable; Received on Tue Jul 01 2003 - 08:27:35 CDT

Original text of this message

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