我想缩短执行时间
$.each(contentUrls, function(i, item) {
$.ajax({
crossOrigin: true,
url: item,
dataType: 'json',
success: function() {
$('#valid' + i).html('V');
},
error: function(err) {
console.log(err.statusCode);
$('#valid' + i).html('X');
},
});
});
答案 0 :(得分:2)
这里是一个简单得多的版本。将来,即使您无法获得执行计划,也无法发布表定义(包括索引),这是一个巨大的帮助。
注意where子句。它使用日期而不是函数来使其可保存。
SELECT sum(case when year(header.[Posting Date]) = 2019 then line.Amount end) AS SaleIn2019
, sum(case when year(header.[Posting Date]) = 2018 then line.Amount end) AS SaleIn2018
, sum(case when year(header.[Posting Date]) = 2017 then line.Amount end) AS SaleIn2017
, sum(case when year(header.[Posting Date]) = 2016 then line.Amount end) AS SaleIn2016
, sum(case when year(header.[Posting Date]) = 2015 then line.Amount end) AS SaleIn2015
FROM [Uneek Clothing Company Ltd$Sales Invoice Header] header
INNER JOIN [Uneek Clothing Company Ltd$Sales Invoice Line] line ON header.No_ = line.[Document No_]
WHERE header.[Sell-to Customer No_] = 'WOR07'
AND line.Type = 2
and header.[Posting Date] >= '20150101'
and header.[Posting Date] < '20200101'