北京周聪项目客商支付join用法
生活随笔
收集整理的這篇文章主要介紹了
北京周聪项目客商支付join用法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
需求:根據每個制單表上客商和項目輔助(不在同一行),統計出每個項目發生的客商支付情況。
sql:感謝南京趙泉
select valuecode, 項目, 客商, sum(貸方), count(*)from (select distinct *from (select b.valuecode,b.valuename 項目,a.valuename 客商,a.貸方,a.制單日期,a.憑證號,a.detailindexfrom (select gl_detail.explanation, bd_accsubj.dispname,gl_detail.debitamount 借方,gl_detail.creditamount 貸方,gl_detail.prepareddatev 制單日期,gl_voucher.no 憑證號,gl_freevalue.valuecode,gl_freevalue.valuename,gl_detail.detailindex,gl_detail.pk_systemvfrom bd_accsubjjoin gl_detailon gl_detail.pk_accsubj = bd_accsubj.pk_accsubjjoin bd_glorgbookon bd_glorgbook.pk_glorgbook =bd_accsubj.pk_glorgbookjoin gl_voucheron gl_detail.pk_voucher = gl_voucher.pk_voucherleft join gl_freevalueon gl_detail.assid = gl_freevalue.freevalueidwhere gl_detail.dr = '0'and gl_detail.explanation <> '期初'and gl_detail.yearv = '2011'and gl_detail.periodv = '07'and bd_glorgbook.glorgbookcode = '010201-0001'and length(gl_freevalue.valuecode) = '11') a ---客商join(select gl_detail.explanation,bd_accsubj.dispname,gl_detail.debitamount 借方,gl_detail.creditamount 貸方,gl_detail.prepareddatev 制單日期,gl_voucher.no 憑證號,gl_freevalue.valuecode,gl_freevalue.valuename,gl_detail.detailindex,gl_detail.pk_systemvfrom bd_accsubjjoin gl_detailon gl_detail.pk_accsubj = bd_accsubj.pk_accsubjjoin bd_glorgbookon bd_glorgbook.pk_glorgbook = bd_accsubj.pk_glorgbookjoin gl_voucheron gl_detail.pk_voucher = gl_voucher.pk_voucherleft join gl_freevalueon gl_detail.assid = gl_freevalue.freevalueidwhere gl_detail.dr = '0'and gl_detail.explanation <> '期初'and gl_detail.yearv = '2011'and gl_detail.periodv = '07'and bd_glorgbook.glorgbookcode = '010201-0001'and length(gl_freevalue.valuecode) = '10') b ---項目on a.制單日期 = b.制單日期and a.憑證號 = b.憑證號))group by valuecode, 項目, 客商order by valuecode效果圖:
轉載于:https://www.cnblogs.com/sumsen/archive/2012/05/26/2519472.html
總結
以上是生活随笔為你收集整理的北京周聪项目客商支付join用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Return to the basic
- 下一篇: Char.IsDigit与Char.Is