Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> select count(*) of a select statement?
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
![]() |
![]() |