List the number and name of all customers.
SELECT CustomerNum, CustomerName
FROM Customer;
List the number and name of all customers that are represented by sales rep 35 or that have credit limits of $10,000.
SELECT CustomerNum, CustomerName
FROM Customer
WHERE RepNum='35' OR CreditLimit=10000;
How many orders were placed on 10/20/2010?
SELECT COUNT(*) AS [Number of Orders]
FROM Orders
WHERE OrderDate=#10/20/2010#;
List all customers that are represented by either Kaiser or Perez.
SELECT CustomerName
FROM Customer, Rep
WHERE Rep.RepNum=Customer.RepNum
AND (Rep.LastName='Kaiser' OR Rep.LastName='Perez');
Question: What happens if we omit the ( ) in the above code? Explain.
List the item class and the sum of the number of units on hand. Also, list the total value of the units on hand.
Group the results by item class.
SELECT Class, SUM(OnHand) AS [Total On Hand], SUM(Price) AS [Total Value]
FROM Part
GROUP BY Class;
Premiere Products would like to know which parts are being ordered by which customers.
For each customer, list the parts ordered (i.e., PartNum and Description) and how many of each part they orderd.
SELECT CustomerName, Part.PartNum, Description, NumOrdered
FROM Customer, Orders, OrderLine, Part
WHERE Customer.CustomerNum=Orders.CustomerNum
AND Orders.OrderNum=OrderLine.OrderNum
AND OrderLine.PartNum=Part.PartNum;