NC65查询期末余额sql

355 篇文章 103 订阅
-- 计算累计发生额

select

org_accountingbook.code 账簿编码,

org_accountingbook.name 账簿名称,

bd_accasoa.dispname 科目名称,

sum(case when adjustperiod='00' then gl_detail.localdebitamount else 0 end) "期初借方",

sum(case when adjustperiod='00' then gl_detail.localcreditamount else 0 end) "期初贷方",

sum(case when adjustperiod='12' then gl_detail.localdebitamount else 0 end) "借方发生",

sum(case when adjustperiod='12' then gl_detail.localcreditamount else 0 end) "贷方发生",

sum(case when adjustperiod>'00' and adjustperiod<='12' then gl_detail.localdebitamount else 0 end) "借方累计",

sum(case when adjustperiod>'00' and adjustperiod<='12' then gl_detail.localcreditamount else 0 end) "贷方累计",

sum(case when adjustperiod<='12' then gl_detail.localdebitamount else 0 end) "借方期末",

sum(case when adjustperiod<='12' then gl_detail.localcreditamount else 0 end) "贷方期末"

from gl_detail gl_detail,org_accountingbook,bd_accasoa,bd_account

where gl_detail.pk_accountingbook=org_accountingbook.pk_accountingbook

and gl_detail.pk_accasoa=bd_accasoa.pk_accasoa

and bd_accasoa.pk_account=bd_account.pk_account

and gl_detail.yearv = '年'

and gl_detail.adjustperiod >= '00'

and gl_detail.adjustperiod <= '12'

and org_accountingbook.code='账簿编码'

and gl_detail.discardflagv <> 'Y'

and gl_detail.dr = 0

and gl_detail.voucherkindv <> 255

and gl_detail.tempsaveflag <> 'Y'

and gl_detail.voucherkindv <> 5

and 1 = 1

group by gl_detail.pk_accasoa,

gl_detail.pk_accountingbook,

gl_detail.yearv,

org_accountingbook.code,

org_accountingbook.name,

bd_accasoa.dispname

原文链接:https://blog.csdn.net/m0_58335762/article/details/128660501

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值