Re: Counting records from multiple tables
Date: Wed, 05 Aug 1998 14:46:50 GMT
Message-ID: <35cd7040.7044118_at_192.86.155.100>
A copy of this was sent to "Jonathan Cox" <jonathan_cox_at_daniel.co.uk> (if that email address didn't require changing) On 5 Aug 98 13:58:31 GMT, you wrote:
>Does anyone know of a way of counting the number of records (to provide a
>grand total) in say 5 tables with just one SQL statement?
>
Here are 2 ways to do it:
SQL> select count(*)
2 from ( select 1 from all_users
3 union all 4 select 1 from all_objects );
COUNT(*)
16307
SQL> select cnt1+cnt2
2 from ( select count(*) cnt1 from all_users ),
3 ( select count(*) cnt2 from all_objects );
CNT1+CNT2
16307
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Opinions are mine and do not necessarily reflect those of Oracle Corporation
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Aug 05 1998 - 16:46:50 CEST