December 13, 2009

MY SQL(II)

(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)));

分類彙整

日曆

December 2009
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

登入界面

  • 使用者

    密碼

    記住帳號及密碼?

POWERED BY
Movable Type 2.661