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 -> select count(*) of a select statement?

select count(*) of a select statement?

From: Jacques Vidal <jvidal_at_mail.dotcom.fr>
Date: Mon, 25 Jun 2001 18:26:08 +0200
Message-ID: <9h7oi3$vq6$1@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:26:08 CDT

Original text of this message

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