Re: Counting Rows

From: Chris Rizzo <abcd_at_efgh.com>
Date: Mon, 19 Mar 2001 15:56:43 -0500
Message-ID: <uyIetZLsAHA.298_at_cpmsnbbsa09>


If you're using SQL Plus, try this:

SQL*Plus>SET FEEDBACK 1

Then run your query

"GZ" <gregz_at_yahoo.com> wrote in message news:3AB4B837.5AAB392F_at_yahoo.com...
> I would like to know how to get a count of the number of rows returned
> by a query WITHOUT having to re-run the query.
>
> The query looks something like this:
>
> select dept, num_persons
> from(
> select dept, num_persons from this_table where.....
>
> UNION ALL
>
> select dept, num_persons from that_table where.....
> )
>
> The end report would look like:
>
> Dept Persons
> ---- -------
> A 4
> B 5
> C 9
> TotalDepts 3
>
> I can achieve this result by putting the whole query again in the
> sub-query with another UNION ALL and wrapping it in a "select count
> from" to get the number of departments, but since we are talking about a
> million rows or more, the time needed for the whole query is doubled. Is
> there another way of doing this more easily?
>
> Greg
>
Received on Mon Mar 19 2001 - 21:56:43 CET

Original text of this message