0

如何将下面的查询重写为消除嵌套查询的联接。

SELECT Company, State2 
FROM Customers
WHERE Id IN 
   (SELECT CustomerId 
    FROM Orders 
    WHERE ((ShipDate BETWEEN '2004-01-1'AND'2004-12-31')AND(Shipping>5.0)));
4

1 回答 1

0
SELECT  DISTINCT a.Company,
        a.State2 
FROM    Customers a
        INNER JOIN Orders b
            ON a.Id = b.CustomerId
WHERE   b.ShipDate BETWEEN '2004-01-01' AND '2004-12-31'
        AND b.Shipping > 5.0

To further gain more knowledge about joins, visit the link below:

于 2013-10-23T01:09:16.343 回答