你的sql效率太差,没这种写法。下面是一个例子,你看懂了问题就解决了。SQL> create table test
  2   (company_id varchar2(30),
  3    pay_month  varchar2(6),
  4    amount     float);
Table created.
SQL> insert into test
  2       values ('a', '200401', 1000);
1 row created.
SQL> insert into test
  2       values ('a', '200402', 800);
1 row created.
SQL> insert into test
  2       values ('a', '200403', 1200);
1 row created.SQL> select   company_id, sum (amount) ttl_amount
  2         , sum (decode (substr (pay_month, 5, 2), '01', amount, 0)) jan
  3         , sum (decode (substr (pay_month, 5, 2), '02', amount, 0)) feb
  4         , sum (decode (substr (pay_month, 5, 2), '03', amount, 0)) mar
  5      from test
  6     where pay_month between '200401' and '200412'
  7  group by company_id;COMPANY_ID                     TTL_AMOUNT        JAN        FEB        MAR
------------------------------ ---------- ---------- ---------- ----------
a                                    3000       1000        800       1200