感谢赵泉提出的gl_freevalue表中的辅助项
select gl_detail.explanation,
bd_accsubj.dispname,
gl_detail.debitamount 借方,
gl_detail.creditamount 贷方,
gl_detail.prepareddatev 制单日期,
gl_voucher.no 凭证号,
wmsys.wm_concat(bd_bdinfo.bdname)辅助名,
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
left join bd_bdinfo
on gl_freevalue.checktype=bd_bdinfo.pk_bdinfo
where gl_detail.dr = '0'
and gl_detail.yearv >= '2010'
and bd_glorgbook.glorgbookcode = '010201-0001'
and gl_detail.explanation<>'期初'
/* and gl_detail.explanation='付财大凤凰楼项目人工费(洪荣森)'*/
--and bd_accsubj.subjcode like '150103%'
group by 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 gl_detail.prepareddatev, gl_voucher.no
效果图: