zoukankan      html  css  js  c++  java
  • 建工项目对账查询引擎sql

    select * from ((select gl_detail.explanation,
           bd_accsubj.dispname,
           gl_detail.debitamount 借方,
           gl_detail.creditamount 贷方,
           gl_detail.yearv,
           gl_detail.periodv ,
           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>=#byear#
        and gl_detail.pk_systemv!='TR'
    and bd_accsubj.subjcode not in('41040107','41040109','41040207','41040209','41040307','41040308')
       and bd_glorgbook.glorgbookcode = (select glorgbookcode from bd_glorgbook where  pk_glbook='0001AA10000000004VTQ' and 
       (substr(glorgbookcode,1,6)=(select unitcode from bd_corp where pk_corp=#LoginCorp#)) )
       and gl_freevalue.valuecode like #duty# ||'%' 
    group by gl_detail.explanation,
              bd_accsubj.dispname,
              gl_detail.creditamount,
              gl_detail.debitamount,
              gl_detail.yearv,
              gl_detail.periodv,
              gl_voucher.no)
     union 
     (select gl_detail.explanation,
           bd_accsubj.dispname,
           gl_detail.debitamount 借方,
           gl_detail.creditamount 贷方,
           gl_detail.yearv,
           gl_detail.periodv ,
           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>=#byear#
    and gl_detail.pk_systemv!='TR'
       and bd_glorgbook.glorgbookcode = (select glorgbookcode from bd_glorgbook where  pk_glbook='0001AA10000000004VTQ' and 
       (substr(glorgbookcode,1,6)=(select unitcode from bd_corp where pk_corp=#LoginCorp#)) )
       and 
    ( bd_accsubj.subjcode  like '2120'||substr(#accsubj#,-2,2)||'%' 
    or
    ( bd_accsubj.subjcode='5402' and gl_detail.explanation like '%' ||#explain#||'%')
    )
     group by gl_detail.explanation,
              bd_accsubj.dispname,
              gl_detail.creditamount,
              gl_detail.debitamount,
              gl_detail.yearv,
              gl_detail.periodv,
              gl_voucher.no))
     order by yearv,periodv,dispname

    
    
  • 相关阅读:
    记一次博客被日的分析过程
    省钱版----查找 IoT 设备TTL线序__未完待续
    于bugku中游荡意外得到关于CBC翻转攻击思路
    清除浮动技巧总结
    程序猿的幸福
    Memcachedclientutils类
    leetcode 2 Add Two Numbers
    arduino小车入门教学——第三天(arduino基础)
    SAP MM模块 经常使用函数
    Java代码格式
  • 原文地址:https://www.cnblogs.com/sumsen/p/2538315.html
Copyright © 2011-2022 走看看