码迷,mamicode.com
首页 > 数据库 > 详细

资金归集率sql

时间:2015-09-01 18:14:21      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

暂时

select bd_glorgbook.glorgbookcode,
nvl(replace(bd_glorgbook.glorgbookname,‘集团基准账薄‘,‘‘),‘小计‘)公司名称, --从萝卜那里学习

bd_accsubj.subjcode,bd_accsubj.subjname,
sum( case when gl_balance.year= ‘2012‘ then gl_balance.debitamount else 0 end) "2012发生额",
sum( case when gl_balance.year= ‘2013‘ then gl_balance.debitamount else 0 end) "2013发生额",
sum( case when gl_balance.year= ‘2014‘ then gl_balance.debitamount else 0 end) "2014发生额" ,
sum( case when gl_balance.year= ‘2015‘ then gl_balance.debitamount else 0 end) "2015发生额"

from gl_balance, bd_accsubj, bd_glorgbook
where gl_balance.pk_accsubj = bd_accsubj.pk_accsubj
and bd_glorgbook.pk_glorgbook = gl_balance.pk_glorgbook
and bd_glorgbook.glorgbookcode like ‘01%-0001‘
and (bd_accsubj.subjcode like ‘2123%‘ or bd_accsubj.subjcode like ‘1131%‘or bd_accsubj.subjcode like ‘1111%‘)
and gl_balance.period<>‘00‘
and gl_balance.year in(‘2012‘,‘2013‘,‘2014‘,‘2015‘)
group by bd_glorgbook.glorgbookcode, rollup((bd_accsubj.subjcode,bd_accsubj.subjname , bd_glorgbook.glorgbookname))

order by bd_glorgbook.glorgbookcode, bd_accsubj.subjcode

资金归集率sql

标签:

原文地址:http://www.cnblogs.com/sumsen/p/4776393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!