最新sql查询金蝶科目余额表个期间的数据.doc

上传人:1595****071 文档编号:47982637 上传时间:2022-10-04 格式:DOC 页数:110 大小:180KB
返回 下载 相关 举报
最新sql查询金蝶科目余额表个期间的数据.doc_第1页
第1页 / 共110页
最新sql查询金蝶科目余额表个期间的数据.doc_第2页
第2页 / 共110页
点击查看更多>>
资源描述

《最新sql查询金蝶科目余额表个期间的数据.doc》由会员分享,可在线阅读,更多相关《最新sql查询金蝶科目余额表个期间的数据.doc(110页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-datesql查询金蝶科目余额表个期间的数据sql查询金蝶科目余额表个期间的数据转载sql查询金蝶科目余额表个期间的数据 select null as QYDM, null as SBNF, null as SBYF, 本期发生_本年累计_科目余额表.会计年度 as会计年度, 本期发生_本年累计_科目余额表.会计期间 as 会计期间, 本期发生_本年累计_科目余额表.借贷方向

2、_1借_负1贷as 借贷方向_1借_负1贷, 本期发生_本年累计_科目余额表.科目级次 as科目级次, 本期发生_本年累计_科目余额表.明细科目_1是_0否 as明细科目_1是_0否, 本期发生_本年累计_科目余额表.科目编码 asKM, 本期发生_本年累计_科目余额表.科目名称 as科目代码, 本期发生_本年累计_科目余额表.本币借方发生额 as本期借方发生数BQJF, 本期发生_本年累计_科目余额表.本币贷方发生额 as本期贷方发生数BQDF, 本期发生_本年累计_科目余额表.本年本币借方发生额 as本年借方发生数BNJF, 本期发生_本年累计_科目余额表.本年本币贷方发生额 as本年贷方

3、发生数BNDF, 年初借方_年初贷方_余额_C.年初借方余额 as年初借方余额NCJF, 年初借方_年初贷方_余额_C.年初贷方余额 as年初贷方余额NCDF, 期初借方_期初贷方_余额_A.期初借方余额 as上期借方余额SQJF, 期初借方_期初贷方_余额_A.期初贷方余额 as上期贷方余额SQDF, 期末借方_期末贷方_余额_B.期末借方余额 as期末借方余额QMJF, 期末借方_期末贷方_余额_B.期末贷方余额 as期末贷方余额QMDF from ( select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + conver

4、t(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + co

5、nvert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID)

6、 ) as本年索引码_年_币_科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本年索引码_年_币_科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Account.FNumber as 科目编码, t_Account.F

7、Name as 科目名称 , t_Balance.FDebit as 本币借方发生额, t_Balance.FCredit as 本币贷方发生额, t_Balance.FYtdDebit as 本年本币借方发生额, t_Balance.FYtdCredit as 本年本币贷方发生额, t_Balance.FAccountID as 科目内码_余额表, t_Account.FAccountID as 科目内码_科目表, t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否 f

8、romt_Balance left outer join t_Account ont_Balance.FAccountID = t_Account.FAccountID where t_Balance.FCurrencyID = 1 ) as 本期发生_本年累计_科目余额表 -左连接<期初借方和期初贷方>余额数据 left outerjoin ( select * from ( select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balanc

9、e.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Ba

10、lance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, ( + t_Bala

11、nce.FBeginBalance ) as 期初借方余额, null as期初贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC = 1科目默认为借方;/2.t_Balance.FBeginBalance >= 0本币期初 大于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC = 1AND t_Balance.FBeginBalance >= 0

12、)and t_Balance.FCurrencyID = 1 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (conv

13、ert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Accoun

14、t.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, null as期初借方余额, ( - t_Balance.FBeginBalance ) as 期初贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC = 1科目默认为

15、借方;/2.t_Balance.FBeginBalance < 0本币期初 小于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC = 1AND t_Balance.FBeginBalance < 0)and t_Balance.FCurrencyID = 1 -以下为 会计科目方向为 <贷方>的语句 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(r

16、trim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltr

17、im(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0

18、否, ( + t_Balance.FBeginBalance ) as 期初借方余额, null as期初贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC = -1科目默认为贷方;/2.t_Balance.FBeginBalance >= 0本币期初 大于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC =-1 AND t_Balance.FBegin

19、Balance > 0)and t_Balance.FCurrencyID = 1 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_

20、年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as

21、会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, null as期初借方余额, ( - t_Balance.FBeginBalance ) as期初贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account

22、.FDC = -1科目默认为贷方;/2.t_Balance.FBeginBalance < 0本币期初 小于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC =-1 AND t_Balance.FBeginBalance <= 0)and t_Balance.FCurrencyID = 1 ) as 期初借方_期初贷方_余额 ) as 期初借方_期初贷方_余额_A on本期发生_本年累计_科目余额表.本期索引码_年月币科目内码 = 期初借方_期初贷方_余额_A.本期索引码_年月币科目内码 left outer

23、 join -左连接<期末借方和期末贷方>余额数据 ( select * from ( select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目

24、内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间,

25、 t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, ( + t_Balance.FEndBalance ) as 期末借方余额, null as期末贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC =

26、 1科目默认为借方;/2.t_Balance.FBeginBalance >= 0本币期初 大于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC = 1AND t_Balance.FEndBalance >= 0)and t_Balance.FCurrencyID = 1 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeri

27、od) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.F

28、CurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, null as期末借方余额, (

29、- t_Balance.FEndBalance ) as 期末贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC = 1科目默认为借方;/2.t_Balance.FBeginBalance < 0本币期初 小于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC = 1AND t_Balance.FEndBalance < 0)and t_Balanc

30、e.FCurrencyID = 1 -以下为 会计科目方向为 <贷方>的语句 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_

31、年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as

32、会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, ( + t_Balance.FEndBalance ) as 期末借方余额, null as期末贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.

33、FDC = -1科目默认为贷方;/2.t_Balance.FBeginBalance >= 0本币期初 大于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC =-1 AND t_Balance.FEndBalance > 0)and t_Balance.FCurrencyID = 1 union all select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance

34、.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本期索引码_年月币科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FPeriod) + - + convert(varchar(10),ltrim(rtrim(t_Bal

35、ance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本期索引码_年月币科目编码, t_Balance.FYear as 会计年度, t_Balance.FPeriod as 会计期间, t_Account.FNumber as 科目编码, t_Account.FName as 科目名称 , t_Account.FDC as 借贷方向_1借_负1贷, t_Account.FLevel as 科目级次, t_Account.FDetail as 明细科目_1是_0否, null as期末借方

36、余额, ( - t_Balance.FEndBalance ) as期末贷方余额 from t_Balance leftouter join t_Account on t_Balance.FAccountID =t_Account.FAccountID -1.t_Account.FDC = -1科目默认为贷方;/2.t_Balance.FBeginBalance < 0本币期初 小于0;/3.t_Balance.FCurrencyID = 1币种 = 人民币;/ where (t_Account.FDC =-1 AND t_Balance.FEndBalance <= 0)and

37、t_Balance.FCurrencyID = 1 ) as 期末借方_期末贷方_余额 ) as期末借方_期末贷方_余额_B on本期发生_本年累计_科目余额表.本期索引码_年月币科目内码 = 期末借方_期末贷方_余额_B.本期索引码_年月币科目内码 -左连接<年初借方年初末贷方>余额数据 left outerjoin ( select * from ( select (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Balance.FAccountID) ) as本年索引码_年_币_科目内码, (convert(varchar(10),ltrim(rtrim(t_Balance.FYear) + - + convert(varchar(10),ltrim(rtrim(t_Balance.FCurrencyID) + - + convert(varchar(20),ltrim(rtrim(t_Account.FNumber) ) as 本年索

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁