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

Home -> Community -> Usenet -> c.d.o.tools -> Re: select count(*) of a select statement?

Re: select count(*) of a select statement?

From: Leandro Teixeira <leandroteixeira_at_netcabo.pt>
Date: Thu, 26 Jul 2001 03:42:12 +0100
Message-ID: <9jo0d0$264$1@venus.telepac.pt>

u can do a thing like this
select count(*)
  from (select whatever from table where whatever) Sub_query

Leandro

"Jacques Vidal" <jvidal_at_mail.dotcom.fr> wrote in message news:9h7oi3$vq6$1_at_s1.read.news.oleane.net...
> Greetings,
>
> Assuming I have a query Q1 where I only identified these 3 syntaxic parts:
>
> (a) the SELECT keyword
> (b) the select list
> (c) everything else that follows the FROM keyword
>
> Or, BNF-speaking:
>
> query ::= select select_list from_and_beyond
>
> Is it always possible to build another query Q2 that returns the number of
> rows Q1 would actually return (ofc assuming nobody updates the table in
 the
> meantime)?
>
> select count(*) from_and_beyond works in the simple case. Eg, if Q1 looks
> like
> SELECT COL2 FROM T1 WHERE COL1 = 'SOMETHING'
> I could do
> SELECT COUNT(*) FROM T1 WHERE COL1 = 'SOMETHING'
> to get the desired result.
>
> However this doesn't work when there's a GROUP BY clause in Q1.
>
> I've been unable to find a solution to this problem. Is there actually one
> that always work, whatever Q1 looks like?
>
> TIA,
>
> Jacques Vidal
>
>
>
Received on Wed Jul 25 2001 - 21:42:12 CDT

Original text of this message

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