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

Home -> Community -> Usenet -> c.d.o.misc -> Re: [Q]HowTo get the count of selected rows

Re: [Q]HowTo get the count of selected rows

From: Roeland Stouthart <oracle_at_worldonline.nl>
Date: 1997/03/19
Message-ID: <01bc33d5$1de181e0$dd141b91@oracle.kpmg.nl>#1/1

> Is it possible to construct a new SQL statement from an arbitrary
> SELECT statement which will always simply return the number of rows
> which would be selected by the original query?
>
> For example, suppose I had the following:
>
> SELECT DISTINCT fld1,fld2 FROM table1;
>
> How can one quickly determine the number of rows that this statement
> will match without actually returning the data. I could simply issue
> the query twice, and count the rows the first time, but I need
> better performance. If DISTINCT was not present in the query above,
> one could simply say
>
> SELECT COUNT(*) FROM table1;

You can still use distinct by putting the whole clause between the parenthises of COUNT()

Roeland Received on Wed Mar 19 1997 - 00:00:00 CST

Original text of this message

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