SELECT *
  FROM 
(select 季,          
       decode(年,'year1996',额度) year1996,
       decode(年,'year1997',额度) year1997,
       decode(年,'year1998',额度) year1998
  from T1
 group by 季,年) T2
GROUP BY 季

解决方案 »

  1.   

    select 季,          
           sum(decode(年,'year1996',额度)) year1996,
           sum(decode(年,'year1997',额度)) year1997,
           sum(decode(年,'year1998',额度)) year1998
      from tablename
     group by 季
      

  2.   

    decode参数 好像差一个0 吧还有 字段名打上双引号吧
      

  3.   

    谢谢各位老大:
    我的语句是这样的,(题目有些变化,sorry)
    select season,          
           sum(decode(year,2000,profit,0)) y2000,
           sum(decode(year,2001,profit,0)) y2001,
           sum(decode(year,2002,profit,0)) y2002,
           sum(decode(year,2003,profit,0)) y2003
      from mytt
      group by season;结果是:
    SQL> @mytest
    Input truncated to 18 charactersSEASON          Y2000      Y2001      Y2002      Y2003
    ---------- ---------- ---------- ---------- ----------
    fall              123        126        133        450
    spring            100        300        156          0
    summer            214        234        254          0
    winter            200        340        109          0