select user_no,
sum(decode(acct_month,'200505',charge,0) 5月金额,
sum(decode(acct_month,'200506',charge,0) 6月金额,
sum(decode(acct_month,'200507',charge,0) 7月金额
from a1 group by user_no
sum(decode(acct_month,'200505',charge,0) 5月金额,
sum(decode(acct_month,'200506',charge,0) 6月金额,
sum(decode(acct_month,'200507',charge,0) 7月金额
from a1 group by user_no
解决方案 »
- 哪里可以下载‘Oracle Database 9i/10g/11g编程艺术深入数据库体系结构中文版2’
- 诚心求助(oracle方面)
- 求一条比较复杂的sql语句!
- oracle9i和oracle10g能装在同一部机上吗?
- 高手请进,一个关于oracle数据库的执行效率问题
- 关于如何表分区提高效率的问题
- select max(ID) from organization 把它取出来后怎么处理才能 insert到 varchar类型的列里?
- 我怎么知道我IMPORT的结果对不对.
- 有人说在ORACLE中可以尽量的使用游标,这样做对吗?
- oracle控制文件有3个,在使用list archive log all命令时,发现不能读取控制文件1,
- 新人安装oracle,不用手把手教,只希望老鸟们给点学习资料。谢谢您的回复
- 求Oracle备份和恢复相关的电子书(在线等待)
sum(b1.5_charge) AS 5月金额,
sum(b1.6_charge) AS 6月金额,
sum(b1.7_charge) AS 7月金额
from
(select user_no,
(case when acct_month= '200505' then
charge
end ) AS 5_charge,
(case when acct_month= '200506' then
charge
end ) AS 6_charge,
(case when acct_month= '200507' then
charge
end ) AS 7_charge
from a1) b1
group by b1.user_no
sum(case acct_month when '200505' then charge else 0 end ) 5月金额,
sum(case acct_month when '200506' then charge else 0 end ) 6月金额,
sum(case acct_month when '200507' then charge else 0 end ) 7月金额
from a1 group by user_no
其实case和decode差不多的,但是case是oracle9i中新增的特性,如果在9i以下的数据库使用是要报错的。