December 06, 2009

SQL(II)

(1)請查詢3號員工所處理的全部訂貨總價(單價*數量)

SELECT SUM(UnitPrice*Quantity) AS 訂貨總價
FROM OrderDetails
WHERE OrderID IN
(SELECT OrderID
FROM Orders
WHERE EmployeeID IN (3));


(2)請查詢出年紀最大的員工編號

SELECT EmployeeID AS 員工編號
FROM Employees
WHERE BirthDate IN
(SELECT min(BirthDate)
FROM Employees);

(3)請查詢出年紀最大的員工所處理的全部訂貨總價(單價*數量) (Join,Group By,Having,SubQuery ,聚合函數)

SELECT SUM(UnitPrice*Quantity) AS 訂貨總價
FROM OrderDetails
WHERE OrderID IN
(SELECT OrderID
FROM Orders
WHERE EmployeeID IN
(SELECT EmployeeID
FROM Employees
WHERE BirthDate IN
(SELECT min(BirthDate)
FROM Employees)));

由 b409097042 發表於 December 6, 2009 09:51 PM
迴響

請查詢3號員工所處理的全部訂貨總價(單價*數量)

Posted by: the bar method 發表於 October 17, 2013 11:23 AM
發表迴響









記住我的資訊?





請依上圖輸入檢核碼: