December 18, 2009

December 12, 2009

MySQL2

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

(2)
SELECT EmployeeID AS 員工編號
FROM Employees
WHERE DateDiff("YYYY",BirthDate,NOW()) IN
(SELECT max(DateDiff("YYYY",BirthDate,NOW()))
FROM Employees);

(3)
SELECT sum(UnitPrice*Quantity)
FROM OrderDetails
WHERE OrderID IN
(
SELECT OrderID
From Orders
WHERE EmployeeID IN
(
SELECT EmployeeID
FROM Employees
WHERE DateDiff("YYYY",BirthDate,NOW()) IN
(SELECT max(DateDiff("YYYY",BirthDate,NOW()))
FROM Employees)
)
)
;

由 b101098135 發表於 08:45 PM | 迴響 (7)