好的,所以我们这里的服务器不是最好的,当我运行这个查询时,它真的会限制使用我们服务器上任何东西的每个人。无论如何我可以使这个查询更有效率吗?我希望能够运行查询,而不会让每个人都吓坏并说我们会减慢查询的速度,基本上是输出
Order Number | OrderDate | Sku | quantity | item price | our shipping $ | number indicating if it is paid | authorizeddate | amazonorderid | ebaybuyerid | Tax | TaxAmount | Shipping |Shipping Amt
该查询返回我需要的所有内容,但我觉得它肯定可以重写。我试过了,但它一直在降低服务器的速度,查询不起作用,我们将不胜感激!
SELECT g.ordernumber,
g.orderdate,
p.sku,
p.quantity,
p.name,
p.unitprice,
s.shipmentcost AS OurPrice,
e.rollupeffectivecheckoutstatus,
' ' AS wonder,
' ' AS AmazonorderID,
e.ebaybuyerid,
f.type AS TAX,
f.amount AS TAXCHARGE,
x.type AS SHIPPING,
x.amount AS ShippingCharge
FROM [ShipWorks].[dbo].[orderitem] p,
[ShipWorks].[dbo].[order] g,
[Shipworks].[dbo].[shipment] s,
[Shipworks].[dbo].[ebayorder] e,
[ShipWorks].[dbo].[ordercharge] f,
[ShipWorks].[dbo].[ordercharge] x
WHERE g.orderid = s.orderid
AND f.orderid = g.orderid
AND x.orderid = g.orderid
AND g.orderid = p.orderid
AND e.orderid = g.orderid
AND f.type = 'TAX'
AND x.type = 'SHIPPING'
AND CONVERT(CHAR(10), orderdate, 120)BETWEEN
( '2013-09-16' ) AND ( '2013-09-17' )
UNION
SELECT t.ordernumber,
t.orderdate,
i.sku,
i.quantity,
i.name,
i.unitprice,
g.shipmentcost,
' ' AS RollupEffectiveCheckoutStatus,
r.authorizeddate,
' ' AS AmazonorderID,
' ' AS EbayBuyerID,
f.type,
f.amount,
x.type,
x.amount
FROM [ShipWorks].[dbo].[order] t,
[ShipWorks].[dbo].[prostoresorder] r,
[ShipWorks].[dbo].[orderitem] i,
[ShipWorks].[dbo].[shipment] g,
[ShipWorks].[dbo].[ordercharge] f,
[ShipWorks].[dbo].[ordercharge] x
WHERE t.orderid = r.orderid
AND t.orderid = i.orderid
AND t.orderid = g.orderid
AND t.orderid = f.orderid
AND t.orderid = x.orderid
AND f.type = 'TAX'
AND x.type = 'SHIPPING'
AND CONVERT(CHAR(10), orderdate, 120)BETWEEN
( '2013-09-16' ) AND ( '2013-09-17' )
UNION
SELECT t.ordernumber,
t.orderdate,
i.sku,
i.quantity,
i.name,
i.unitprice,
q.shipmentcost,
' ' AS RollupEffectiveCheckoutStatus,
' ' AS AuthorizedDate,
a.amazonorderid,
' ' AS EbayBuyerID,
f.type,
f.amount,
x.type,
x.amount
FROM [ShipWorks].[dbo].[order] t,
[ShipWorks].[dbo].[amazonorder] a,
[ShipWorks].[dbo].[orderitem] i,
[ShipWorks].[dbo].[shipment] q,
[ShipWorks].[dbo].[ordercharge] f,
[ShipWorks].[dbo].[ordercharge] x
WHERE t.orderid = a.orderid
AND t.orderid = f.orderid
AND t.orderid = x.orderid
AND t.orderid = i.orderid
AND t.orderid = q.orderid
AND f.type = 'TAX'
AND x.type = 'SHIPPING'
AND CONVERT(CHAR(10), orderdate, 120)BETWEEN
( '2013-09-16' ) AND ( '2013-09-17' ) `