select distinct 年,[季度1]=(select 金额 from tablename where 年=a.年 and 季度=1)
,[季度2]=(select 金额 from tablename where 年=a.年 and 季度=2)
,[季度3]=(select 金额 from tablename where 年=a.年 and 季度=3)
,[季度4]=(select 金额 from tablename where 年=a.年 and 季度=4)
from tablename a
,[季度2]=(select 金额 from tablename where 年=a.年 and 季度=2)
,[季度3]=(select 金额 from tablename where 年=a.年 and 季度=3)
,[季度4]=(select 金额 from tablename where 年=a.年 and 季度=4)
from tablename a
季度2= case 季度 when 2 then sum(金额) else 0
from 表 group by 年,季度