You are on page 1of 2

Tables:

Customers: Orders: Shippers:


CustomerID OrderID ShipperID
CustomerName CustomerID ShipperName
ContactName EmployeeID Phone
Address OrderDate
City ShipperID
PostalCode
Country

Categories: Employees: Products:

EmployeeID ProductID
CategoryID
LastName ProductName
CategoryName
FirstName SupplierID
Description
Birthdate CategoryID
Photo Unit
Notes Price
OrderDetails:

OrderDetailsID
OrderID
ProductID
Quantity

Suppliers

SupplierID
SupplierName
ContactName
Address
City
PostalCode
Country
Phone

1. Create a view that selects every product in the ‘Products’ table with a price higher than the
average price.
2. Write a query to get the Category for which the highest number of Products have been
ordered.
3. Write a query to get the Customer and Shipper information where the same customer has
been serviced by a shipper the maximum number of times along with the date of service
4. In table Order Details, I want to append the OrderID with the Category name and ProductID
for each order
5. Which employee and shipper combination has serviced maximum number of Customers.
https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all

2.

SELECT * FROM [Products]


where ProductID =(select ProductID from OrderDetails where Quantity = (select
max(Quantity) from OrderDetails));

3. select count(CustomerID),CustomerName from customers,shippers


group by CustomerName;

4. update orderDetails
set OrderID = (select CategoryName from categories where OrderID = CategoryID)
;

5. SELECT max(EmployeeID),max(ShipperID),CustomerID FROM [Orders]


group by CustomerID

You might also like