查询过去需要大约1个小时,现在需要3个小时。 一个问题是,我们发现表DT_L_Item的大小增加了,原因是添加了Items,而ut仍在寻找是否可以做些什么。 请帮助
查询:-
select a12.CPY ,
a13.MANUFACTURER MANUFACTURER,
a11.COMPANY COMPANY,
a13.CATEGORY ,
a11.BACKOFFICE ,
a12.ABC ,
sum((Case when a11.ID_MONTH in (201701) then a11.VL_LANDED_COGS_TCY else NULL end)) WJXBFS1,
sum((Case when a11.ID_MONTH in (201701) then a11.VL_NET_SALES_TCY else NULL end)) WJXBFS2,
(Case when max((Case when a11.ID_MONTH in (201701) then 1 else 0 end)) = 1 then count(distinct (Case when a11.ID_MONTH in (201701, 201702, 201703, 201704, 201705, 201706) then a11.ID_MONTH else NULL end)) else NULL end) WJXBFS3,
sum((Case when a11.ID_MONTH in (201701) then a11.VL_GLOBAL_COGS_TCY else NULL end)) WJXBFS4,
sum((Case when a11.ID_MONTH in (201701) then a11.VL_SPECIAL_TAX_TCY else NULL end)) WJXBFS5,
sum((Case when a11.ID_MONTH in (201801) then a11.VL_LANDED_COGS_TCY else NULL end)) WJXBFS6,
(Case when max((Case when a11.ID_MONTH in (201801) then 1 else 0 end)) = 1 then count(distinct (Case when a11.ID_MONTH in (201801, 201802, 201803, 201804, 201805, 201806) then a11.ID_MONTH else NULL end)) else NULL end) WJXBFS7,
sum((Case when a11.ID_MONTH in (201801) then a11.VL_NET_SALES_TCY else NULL end)) AYP_Sales_last_3_Months,
sum((Case when a11.ID_MONTH in (201801) then a11.VL_SPECIAL_TAX_TCY else NULL end)) WJXBFS8,
sum((Case when a11.ID_MONTH in (201801) then a11.VL_GLOBAL_COGS_TCY else NULL end)) WJXBFS9
from FV_SALES a11
join DT_L_Item a12
on (a11.COMPANY = a12.COMPANY and
a11.ITEM = a12.ITEM)
join DT_G_Item a13
on (a11.G_ITEM = a13.ITEM)
join LV_COMPANY a14
on (a11.COMPANY = D_COMPANY)
where (a11.ID_COMPANY in (ABC)
and (a11.MONTH in (201701)
or a11.MONTH in (201801)))
group by a12.CPY ,
a13.MANUFACTURER MANUFACTURER,
a11.COMPANY COMPANY,
a13.CATEGORY ,
a11.BACKOFFICE ,
a12.ABC