又不是插入或修改触发的事件,建议用过程做,或者SQL做.
用过程很容易的,用SQL的话不是很容易来显示SUM(A),SUM(B)等,除非就只有这么两种!
用过程做如下:
DECLARE
   CURSOR CUR_TEST AS SELECT FIELD1,SUM(FIELD2) SUM1 FROM TABLENAME GROUP BY FIELD1;
BEGIN
   FOR CUR_EMP IN CUR_TEST
   LOOP
       INSERT INTO TABLENAME VALUES('SUM('||CUR_EMP.FIELD1||')',CUR_EMP.SUM1);
   END LOOP;
END;

解决方案 »

  1.   

    一个SQL就能实现zhang@zhang>select col1, col2 from test2
      2  union all 
      3  select 'sum('||col1||')' col1, sum(col2) col2
      4  from test2
      5  group by col1;COL1                  COL2
    --------------- ----------
    a                        2
    a                       12
    b                       20
    b                     3434
    sum(a)                  14
    sum(b)                3454
      

  2.   

    需要这么复杂吗?
    select col1,sum(col2) from table group rollup(col1)
      

  3.   

    select 'col1'||col1,col2 from test_2  
    union all
    select 'sum('||col1||')' col1,sum(col2) from test_2 group by col1
      

  4.   

    select no,val from test_2;        NO        VAL
    ---------- ----------
             1          1
             1          2
             1          3
             2          4
             2          5select ''||no no,val from test_2
        union all
        select 'sum('||no||')' no,sum(val) from test_2 group by no;NO                       VAL
    ------------------  --------
    1                          1
    1                          2
    1                          3
    2                          4
    2                          5
    sum(1)                     6
    sum(2)                     97 rows selected