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;
这段Oracle语句的优化
答案:1 悬赏:40 手机版
解决时间 2021-05-25 23:10
- 提问者网友:轮囘Li巡影
- 2021-05-25 01:03
最佳答案
- 五星知识达人网友:等灯
- 2021-05-25 01:28
语句写的没什么问题,需要为语句中出现的字段建索引,如下:Create Index ix_account On Account(item_no,section_no,store_no,sales_cost)Create Index ix_items On items(item_no,sell_vat)Create Index ix_store_sections On store_sections(Name,store_no)Create Index ix_vat On vat(vat_no,perc)如果还是很慢,则需要考虑别的机制来查询,可以将统计结果存在一个临时表,页面数据从临时表取,写个作业调度sql不停的更新临时表里面的统计信息
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯