160 likes | 274 Views
Example 18. SELECT count(*) FROM Part WHERE Class="HW";. Example 19. SELECT count(*), Sum(Balance) FROM Customer;. Example 20. SELECT count(*) AS CustomerCount, Sum(Balance) AS BalanceTotal FROM Customer;. Example 21. SELECT OrderNum FROM OrderLine
E N D
Example 18 SELECTcount(*) FROM Part WHERE Class="HW";
Example 19 SELECT count(*), Sum(Balance) FROM Customer;
Example 20 SELECT count(*) AS CustomerCount, Sum(Balance) AS BalanceTotal FROM Customer;
Example 21 SELECT OrderNum FROM OrderLine WHERE PartNum IN (SELECT PartNum FROM Part WHERE Warehouse='3');
Example 22 SELECT RepNum, Count(*)AS NumOfCustomer, Avg(Balance) AS AvgBalance FROM Customer GROUP BY RepNum
Example 23 SELECTRepNum, count(*) AS NumCustomer, Avg(Balance) AS AverageBalance FROM Customer GROUP BYRepNum HAVINGCount(*)<4;
Example 23-1 SELECTRepNum, count(*) AS NumCustomer, Avg(Balance) AS AverageBalance FROM Customer WHERECreditLimit<10000 GROUP BYRepNum HAVINGCount(*)<3;
Example 24 SELECT CustomerNum, CustomerName, Rep.RepNum, LastName, FirstName FROM Customer, Rep WHERERep.RepNum=Customer.RepNum;
Example 25 SELECT CustomerNum, CustomerName, Rep.RepNum, LastName, FirstName FROM Customer, Rep WHERE Rep.RepNum=Customer.RepNum ANDCreditLimit=10000;
Example 26 SELECTOrders.OrderNum, Orderdate, Customer.CustomerNum, CustomerName, Part.PartNum, Description, NumOrdered, QuotedPrice FROM Orders, Customer, OrderLine, Part WHERECustomer.CustomerNum=Orders.CustomerNumANDOrders.OrderNum=OrderLine.OrderNum AND OrderLine.PartNum=Part.PartNum;
Example 27 SELECT CustomerNum, CustomerName FROM Customer WHERE RepNum='35' UNION SELECT Customer.CustomerNum, CustomerName FROM Customer, Orders WHERE Customer.CustomerNum=Orders.CustomerNum;
Example 28 UPDATE Customer SET Street = '1445 Rivard' WHERE CustomerNum='524';
Example 29 INSERT INTO Rep VALUES ('16', 'Rands', 'Shron', '826 Raymond', 'Altonville', 'FL', '32543', 0, 0.05);
Example 30 DELETE * FROM OrderLine WHERE PartNum='BV06';
Example 31 SELECT * INTO SmallCust FROM Customer WHERE CreditLimit<=7500;
Example 32 INSERT INTO Employee VALUES('987654321', 'Choi', 'Yong', '9001 Stockdale', 'Bakersfield', 'CA', '123456789');