[补充工程统计case]科技活动经费sql2014
select bd_glorgbook.glorgbookcode,bd_glorgbook.glorgbookname,
gl_detail.explanation,
bd_accsubj.dispname,
gl_detail.debitamount 借方,
gl_detail.creditamount 贷方,
gl_detail.prepareddatev 制单日期,
gl_voucher.no 凭证号,
wmsys.wm_concat(gl_freevalue.valuecode) valuecode,
wmsys.wm_concat(gl_freevalue.valuename) valuename,
gl_detail.pk_systemv,
gl_detail.detailindex
from bd_accsubj
join gl_detail
on gl_detail.pk_accsubj = bd_accsubj.pk_accsubj
join bd_glorgbook
on bd_glorgbook.pk_glorgbook = bd_accsubj.pk_glorgbook
join gl_voucher
on gl_detail.pk_voucher = gl_voucher.pk_voucher
left join gl_freevalue
on gl_detail.assid = gl_freevalue.freevalueid
where gl_detail.dr = ''
and ( bd_accsubj.subjcode like '4104010508%'or bd_accsubj.subjcode like '550212%') and bd_glorgbook.glorgbookcode like '01%-0001'
and gl_detail.yearv = ''
/* and gl_detail.creditamount ='0'*/
and gl_detail.explanation<>'期初'
and gl_detail.debitamount<>0
/* and gl_detail.explanation='付财大凤凰楼项目人工费(洪荣森)'*/
--and bd_accsubj.subjcode like '150103%'
group by bd_glorgbook.glorgbookcode,bd_glorgbook.glorgbookname, gl_detail.explanation,
bd_accsubj.dispname,
gl_detail.creditamount,
gl_detail.debitamount,
gl_detail.prepareddatev,
gl_voucher.no,
gl_detail.pk_systemv,
gl_detail.detailindex
order by bd_glorgbook.glorgbookcode, bd_accsubj.dispname,gl_detail.prepareddatev, gl_voucher.no
发给建行的
select-- bd_glorgbook.glorgbookcode,
--bd_glorgbook.glorgbookname,
--gl_detail.prepareddatev 制单日期,
-- gl_voucher.no 凭证号,
-- gl_detail.explanation,
gl_detail.yearv,
bd_accsubj.dispname,
sum(gl_detail.debitamount) 金额
-- gl_detail.creditamount 贷方,
from gl_detail, bd_accsubj, bd_glorgbook, gl_voucher
where gl_detail.pk_accsubj = bd_accsubj.pk_accsubj
and gl_detail.pk_glorgbook = bd_glorgbook.pk_glorgbook
and gl_detail.pk_voucher = gl_voucher.pk_voucher
and gl_detail.dr = ''
and gl_detail.periodv<>''
and gl_detail.debitamount<>0
and gl_detail.yearv in ('','','')
--and bd_glorgbook.glorgbookcode = '010201-0001'
--and (gl_voucher.no='263' or gl_voucher.no='207')
and (bd_accsubj.subjcode like '550212%' or bd_accsubj.subjcode like '4104010508%')
and bd_glorgbook.glorgbookcode like '01%'
group by gl_detail.yearv,bd_accsubj.dispname
order by gl_detail.yearv,bd_accsubj.dispname

下面是rollup安装分公司小计
select bd_glorgbook.glorgbookcode,
nvl(replace(bd_glorgbook.glorgbookname,'集团基准账薄',''),'小计')公司名称, --从萝卜那里学习 bd_accsubj.subjcode,bd_accsubj.subjname,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) "2010发生额",
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) "2011发生额",
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) "2012发生额" 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 '5502%' or bd_accsubj.subjcode like '5503%')
and gl_balance.period<>''
and gl_balance.year in('','','')
group by bd_glorgbook.glorgbookcode, rollup((bd_accsubj.subjcode,bd_accsubj.subjname , bd_glorgbook.glorgbookname)) order by bd_glorgbook.glorgbookcode, bd_accsubj.subjcode

2014.9.10 更新
统计各个公司2010-2014费用
期间发生了问题,sum的时候里面不能是数字和汉字的组合,否则


单位取到万
select glorgbookcode,公司名称,
( case substr(subjcode,1,4)
when '' then '管理费用'
when '' then '财务费用'
when '' then '投资收益'
when '' then '营业外收入'
else '营业外支出' end
)"会计科目",
round(sum(A)/10000,2)"2010发生额",round(sum(B)/10000,2) "2011发生额",round(sum(C)/10000,2)"2012发生额",round(sum(D)/10000,2) "2013发生额",round(sum(E)/10000,2) "2014发生额"
from ( select bd_glorgbook.glorgbookcode,
nvl(replace(bd_glorgbook.glorgbookname,'集团基准账薄',''),'小计')公司名称, --从萝卜那里学习 bd_accsubj.subjcode,bd_accsubj.subjname,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) A,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end)B,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) C,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) D,
sum( case when gl_balance.year= '' then gl_balance.debitamount else 0 end) E 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 '5502%' --管理费用
or bd_accsubj.subjcode like '5503%' -- 财务费用
or bd_accsubj.subjcode like '5201%' --投资收益
or bd_accsubj.subjcode like '5301%' --营业外收入
or bd_accsubj.subjcode like '5601%' --营业外支出
)
and gl_balance.period<>''
and gl_balance.year in('','','','','')
group by bd_glorgbook.glorgbookcode, bd_accsubj.subjcode,bd_accsubj.subjname , bd_glorgbook.glorgbookname order by bd_glorgbook.glorgbookcode, bd_accsubj.subjcode)
group by glorgbookcode,公司名称,substr(subjcode,1,4)
order by glorgbookcode,substr(subjcode,1,4)

[补充工程统计case]科技活动经费sql2014的更多相关文章
- 大数据学习----day27----hive02------1. 分桶表以及分桶抽样查询 2. 导出数据 3.Hive数据类型 4 逐行运算查询基本语法(group by用法,原理补充) 5.case when(练习题,多表关联)6 排序
1. 分桶表以及分桶抽样查询 1.1 分桶表 对Hive(Inceptor)表分桶可以将表中记录按分桶键(某个字段对应的的值)的哈希值分散进多个文件中,这些小文件称为桶. 如要按照name属性分为3个 ...
- 数据分组、统计 case when then else end
case when 对表进行条件分组 case简单函数 case age when then select name , sex , age , ( case age /*when 条件成立 ...
- 并列统计CASE WHEN
select sum(case when depart = 'Physical' then 1 else 0 end) PhyTotal, sum(case when depart = 'Chemis ...
- javaWeb代码工程统计
直接放在src/test/java包内运行 /** * 代码行数统计 * @author ThinkGem * @version 2014-7-22 */ public class CodeCount ...
- 微软Azure AspNetCore微服务实战第1期【补充2017-09-09活动】
2017年09月09日,冒着酷暑,我们在(上海徐汇)虹桥路3号港汇中心2座10层组织了一次微软Azure AspNetCore微服务实战活动. 由于前期工作繁忙,活动完成之后,没能及时发布相关信息,特 ...
- Android: Intent实现活动之间的交互
Intent的作用:是Android中各个组件直接交互的一种重要方式,且利用Intent可以启动Activity.Service以及Broadcast Receiver. Intent的创建:显示和隐 ...
- 本招聘信息2014年长期有效!杭州派尔科技高薪诚聘android开发(10K-20K),web前端开发(8K-15K),IOS开发(15K-25K)
杭州派尔科技有限公司发展至今,离不开员工的无私奉献和辛勤耕耘,在努力创造更好成绩的同时,公司也不忘回馈每一位员工的努力与付出.1.全面的绩效考核机制,让发展空间近在眼前!公司力争让每一位员工都了解自己 ...
- android switch语句报错:case expressions must be constant expressions
今天无意中碰见了 case expressions must be constant expressions 的问题 写了一个 switch(item.getItemId()) { case R. ...
- (转)Delphi工程文件说明
1.DPR: Delphi Project文件,包含了Pascal代码.应用系统的工程文件2.PAS: Pascal文件,Pascal单元的源代码,可以是与窗体有关的单元或是独立的单元.3.DFM:D ...
随机推荐
- Java Integer的底层优化
看一个程序(腾讯题) public class showMain { public static void main(String[] args){ //Double i1=127.00,i2=127 ...
- $.post 请求一直转圈圈,谷歌浏览器状态一直为canceled
最开始写的是 $.post("url",{},function(){},"json") 用火狐浏览器 测试发现请求一直在转圈圈 ,就在action输出 发现也进 ...
- WCF初探-6:WCF服务配置
WCF服务配置是WCF服务编程的主要部分.WCF作为分布式开发的基础框架,在定义服务以及定义消费服务的客户端时,都使用了配置文件的方法.虽然WCF也提供硬编程的方式,通过在代码中直接设置相关对象的属性 ...
- codeforces 451E Devu and Flowers
题意:有n个瓶子每个瓶子有 f[i] 支相同的颜色的花(不同瓶子颜色不同,相同瓶子花视为相同) 问要取出s支花有多少种不同方案. 思路: 如果每个瓶子的花有无穷多.那么这个问题可以转化为 s支花分到 ...
- python leetcode 日记--Maximal Square--221
题目: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ...
- c#用牛顿法计算根号下2的值
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- HTML5 的data-* 自定义属性
HTML5增加了一项新功能是自定义数据属性,也就是 data-*自定义属性. 在HTML5中我们可以使用以data-为前缀来设置我们需要的自定义属性,来进行一些数据的存放. 当然高级浏览器下可通过脚本 ...
- (C语言)结构体成员的引用->(箭头)和 .(点)
关于结构体成员的引用有这样的规律: 箭头(->):左边必须为指针: 点号(.):左边必须为实体. 那么如果一个结构体指针引用一个成员,这个成员又是一个结构体(并且是一个实体),那么如果要引用这个 ...
- Python学习路程day12
前端内容学习:HTML和CSS <!DOCTYPE html> <html lang="en"> <head> <meta http-eq ...
- Qt Creator提示"Qt没有被正确安装,请运行make install"的解决办法
笔者最近使用Qt在开发一些小程序,觉得这个框架设计确实很好,使用了信号和槽解决了组件之间的通讯问题,可以说是基于C++语言上一个非常大的创新,大大提高了开发人员的编码效率,也使整个C++语言更加抽象. ...