想查询的是借方和贷方金额的。
如果不加括号,查询不仅慢,并且效率低。
select 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 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 = '0' and gl_detail.yearv = '2011' and bd_glorgbook.glorgbookcode = '0100-0001' and (gl_detail.debitamount='6202549' or gl_detail.creditamount='6202549') --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 order by gl_detail.prepareddatev, gl_voucher.no