Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: [Q]HowTo get the count of selected rows
In article <3329B8DD.1FB4_at_ramoth.ess.sandia.gov>,
Randall Smith <rbsmith_at_ramoth.ess.sandia.gov> wrote:
>Hello,
>
>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;
SELECT COUNT(DISTINCT fld1, fld2) FROM table1;
This would do the trick, but it still means you issue the query twice.
Stefan.
Name :G.R.S. Deisz Phone :+31-50-5855954 E mail :G.R.S.Deisz_at_PTT-Telecom.Unisource.NL DISCLAIMER:This statement is not an official statement from, nor does it represent an official position of, PTT Telecom BV.Received on Tue Mar 18 1997 - 00:00:00 CST
![]() |
![]() |