本帖最后由 qiubi 于 2010-11-24 23:05:57 编辑

解决方案 »

  1.   

    在存储过程或函数中使用动态SQL可以解决!
      

  2.   

    select trunc(time),count(*) from (
    select id,name,time from 表A union all
    select id,name,time from 表B union all
    select id,name,time from 表C union all
    select id,name,time from 表D )  group by trunc(time); 
    --如果表很多,可以写一个存储过程动态拼接如上形式的SQL返回数据集
      

  3.   

    我同意这个,把所有的表union all起来,然后再分组统计即可。
      

  4.   

    select time,count(*) cnt
    from (select time,name from a
    union all 
    select time,name from b
    union all
    select time,name from c
    union all
    select time,name from d)
    group by time
      

  5.   

    select table_name,num_rows from user_tables where table_name in ('A','B','C','D');如果没有记录数,先analyze一下表analyze table a compute statistics;
      

  6.   

     with temp as (select id,name,time from 表A union all
    select id,name,time from 表B union all
    select id,name,time from 表C union all
    select id,name,time from 表D)
      select trunc(time),count(*) from temp group by trunc(time)