我有這兩個查詢。我不知道如何將它們結合在一起製作派生表。我假設使用第二個查詢作爲主查詢,並在主查詢的FROM子句中使用第一個查詢。SQL Server中的派生表
SELECT EmailAddress, Orders.OrderID, SUM(ItemPrice * Quantity) AS OrderTotal
FROM Customers
JOIN Orders ON Customers.CustomerID = Orders.CustomerID
JOIN OrderItems ON Orders.OrderID = OrderItems.OrderID
GROUP BY EmailAddress, Orders.OrderID;
SELECT EmailAddress, MAX(ItemPrice) as LargestOrder
FROM Customers
JOIN Orders ON Customers.CustomerID = Orders.CustomerID
JOIN OrderItems ON Orders.OrderID = OrderItems.OrderID
GROUP BY EmailAddress
什麼是你正在試圖做的查詢? – 2014-02-19 18:41:29
您是否試圖獲得由客戶提供的單筆訂單總額或總額訂單總額的最大值? – Miller
我試圖將兩個查詢的結果合併到一個表中 – jaramore