SELECT ; C.CustomerID, ; C.CompanyName, ; (SELECT YTD_Sales FROM Sales_02 WHERE ; C.CustomerID = Sales_02.CustomerID) AS Y02,; (SELECT YTD_Sales FROM Sales_03 WHERE ; C.CustomerID = Sales_03.CustomerID) AS Y03,; (SELECT YTD_Sales FROM Sales_04 WHERE ; C.CustomerID = Sales_04.CustomerID) AS Y04 ; FROM Customers C |
SELECT ; C.customerID, ; C.companyname, ; SUM(D.quantity*D.unitprice) AS CustTotal ,; (SUM(D.quantity*D.unitprice) / ; (SELECT SUM((quantity*unitprice)-discount) ; FROM OrderDetails D2) ; )*100 AS PctTotal ; FROM Customers C ; INNER JOIN Orders O ; ON C.customerID = O.customerID ; INNER JOIN OrderDetails D ; ON O.orderid = D.orderid ; GROUP BY C.customerID, C.companyname, O.orderID ; ORDER BY pctTotal DESC |
SELECT ; C.customerid, ; P.prodUCt_count AS p_count; FROM Customers C, ; (SELECT c2.customerid, ; COUNT(DISTINCT D.productID) AS p_count ; FROM Customers C2 ; INNER JOIN Orders O ; ON C2.customerid = O.customerid ; INNER JOIN OrderDetails D ; ON O.orderid = D.orderid ; GROUP BY c2.customerid) AS P ; WHERE C.customerID = p.customerID ; AND P.p_count >= ; (SELECT (COUNT(*)*.50) FROM Products) ; ORDER BY p.product_count DESC |
DELETE products ; FROM mfg ; WHERE mfg.productID = products.productID; AND mfg.discontinued = .t. |
UPDATE products ; SET unitprice = mfg.msrp *.90 ; FROM mfg ; WHERE mfg.productID = products.productID |
UPDATE products ; SET unitprice = ; (SELECT ( msrp *.90 ) ; FROM mfg ; WHERE mfg.productID = products.productID) |
INDEX ON DELETED() TAG DELETED |
新闻热点
疑难解答