永发信息网

这段ORACLE语句还有优化的余地吗?

答案:1  悬赏:70  手机版
解决时间 2021-05-14 01:41
  • 提问者网友:战魂
  • 2021-05-13 19:35
 select A.paycomp,
                           fg_customfile.compname,--客户.单位名称
                           fg_customfile.roadno,--客户.配送路线
                           '' as roadname,
                           enterprise.address1,--往来单位.单位住址
                           '' as isaddhurry,
                           '' as isselfcarry,
                           (Case
                             When Exists (Select 1
                                     From ec_sendermst B
                                    Where A.Paycomp = B.Paycomp
                                      And B.Sendtype = 'T') Then
                              0
                             Else
                              1
                           End) as isred,
                           sum(decode(sendtype,'F',ec_senderdtl.sendsum)) as fsendsum, --发货单金额
                           sum(decode(sendtype,'T',ec_senderdtl.sendsum)) as tsendsum, --退货单金额
                           (sum(ec_senderdtl.sendsum)) as invsum
                      from ec_sendermst A, ec_senderdtl, fg_customfile, enterprise
                     where A.ocode = AS_OCODE
                       and (A.sendtype <> 'Y' and A.sendtype <> 'D')
                       and A.sendid = ec_senderdtl.sendid
                       and A.appflg = 1
                       and ec_senderdtl.orgflg = 1 --是否原行(1:原行,0或null: 非原行)
                       and fg_customfile.ocode = '001'
                       and fg_customfile.compno = A.paycomp --客户.单位代码=发货单主表.结算单位
                       and fg_customfile.compno = enterprise.compno--客户.单位代码=往来单位.单位代码
           -- 发货单类型('F'发货单、'T'退货单、'E'换货型退货单、'H'换货单、'D'调拨单、'C'调整单、‘Y'移库单,'I':委托代销初始单据)      --销售性质(01经销、02代销、03直销、04内调、05转储)
                       and A.sendtype in ('D', 'F', 'T', 'E', 'H', 'I') and A.salepre in ('01','03')
                       --开贷项凭单状态(0,未开 1,部分 2,全部)
                       and (ec_senderdtl.makebalflg is null or ec_senderdtl.makebalflg = 0 or ec_senderdtl.makebalflg = 1)
                       --标准数量 * (标准数量-开贷项凭单数量)
                       and ec_senderdtl.sqty * (ec_senderdtl.sqty - nvl(ec_senderdtl.smakebalqty, 0)) > 0
                       group by A.paycomp,fg_customfile.compname,fg_customfile.roadno,enterprise.address1;
最佳答案
  • 五星知识达人网友:笑迎怀羞
  • 2021-05-13 19:52
一种数据库编程语言:结构化查询语言(Structured Query Language)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯