Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: select count(*) of a select statement?
SELECT count(*)
FROM (<your original query goes here>)
"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 Mon Jun 25 2001 - 11:51:57 CDT