最近做报表,第一次做,很多不会,希望大家给点指导意见
有什么想法都说出来,谢谢要做这样一个报表A   a   b  c  
   ...  ... ...
--------------
total:       --A的总汇
B   d   e  f  
   ...  ... ...
--------------
total:       --B的总汇
--------------------
ALL:        --A、B的总汇请问用select怎么做 , 或者用proc怎么写还有一个报表时这样的A   a1  a2  a3  
B  b1:.. b2:..
...  ...  ... ...
--------------
total:       --B的总汇
C  c1:.. c2:..
...  ...  ... ...
--------------
total:       --C的总汇
--------------------
ALL:        --B、C的总汇

解决方案 »

  1.   

    需求有些模糊,你最好把表格定义,内容,想得到的结果写出来,这样才好回答。猜测你想要的结果是类似这样的with t (id, col1) as (
              select 'A', 10 from dual
    union all select 'A', 25 from dual
    union all select 'B', 20 from dual
    union all select 'B', 30 from dual
    )
    select case grouping(id) when 0 then id else 'All' end id,
      sum(col1) from t group by rollup(id);结果
    ID  SUM(COL1)              
    --- ---------------------- 
    A   35                     
    B   50                     
    All 85                     3 rows selected