okay, so our server here at work isn't the best, and when I run this query it really throttles down everyone using anything on our server. Is there anyway I can make this query more efficient? I'd like to be able to run the query without everyone freaking out and say we are going slow the query basically outputs
Order Number | OrderDate | Sku | quantity | item price | our shipping $ | number indicating if it is paid | authorizeddate | amazonorderid | ebaybuyerid | Tax | TaxAmount | Shipping |Shipping Amt
The query returns everything I need, but I feel it could definitely be rewritten. I tried but it kept slowing down the server with queries that weren't working any help would be appreciated!
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' ) `