-
counting the number of records from multiple tables
i have nearly 10 to 15 tables of names like %price1%
i want an output of the form
tablename count(*)
---------------------
price1 200
price2 335
price3 634
...
...
..
could someone help me to phrase a query.
-
Any replies to this please ....
Any replies to this please ....
-
Code:
select 'price1' table_name, count(*) num_rows from price1
union all
select 'price2' table_name, count(*) num_rows from price2
union all
select 'price3' table_name, count(*) num_rows from price3
union all
...
order by 1
-
Hi Dave,
thanks for the reply, but in this case i want the table names to be framed up automatically by oracle, as there might be many tables also at times.
any other alternates much appreciated.
-
Originally Posted by perot
Hi Dave,
thanks for the reply, but in this case i want the table names to be framed up automatically by oracle, as there might be many tables also at times.
any other alternates much appreciated.
You can't directly select from a table without knowing the name of the table. You can use dynamic sql to create a query if you have a table that stores all of the tables you want to select from, you can also concatenate a bunch of stuff together and create a cursor to select from. how do you know what tables you want in the select?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|