December 13, 2009

程式設計--SQL(II)的練習

程式設計--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 MAX(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 MAX(BirthDate)
FROM Employees)));

由 b202098072 發表於 December 13, 2009 08:22 PM
迴響
發表迴響









記住我的資訊?





請依上圖輸入檢核碼: