Вы находитесь на странице: 1из 5

B. Import Data: Use SQL statements to import the data into the tables you just created.

You will come up with each of your data sets yourself. You should have at least five
records for each table. Include screenshots that show the populated tables annotated
with the SQL statements that you used

1.’

SELECT * FROM `order history` WHERE 1;

2.
SELECT * FROM `books`;
3.
SELECT * FROM `bookstore`;
4.
SELECT `ordernum`, `customername`, `customeremail`, `phonnumber`, `customerID` FROM`customer`
;

5.
SELECT `zipcode`, `order_date`, `employeeName`, `address`, `phonnumber`, `hire_date`, `employ
eeID` FROM `employee`;
6.
SELECT `orderamt`, `order_date`, `orderdetails`, `pymmethod`, `order_no` FROM `order_`;

7.
SELECT `productprice`, `productdesc`, `productID`, `productname` FROM `product`;

C. Queries: After you have populated the tables, write queries to extract the data to
answer the owner's questions. Include screenshots that show each query and the
corresponding query results.
--How many books are sole each month by the publisher?
SELECT PublisherName, COUNT (*)
FROM OrderHistory OH JOIN Books B
ON OH.BookID = B.BookID
GROUP BY PublisherName;

--Which authors are the biggest sellers of books in our stores?


SELECT BookAuthor FROM Books
WHERE BookID = (SELECT TOP 1 COUNT (*) FROM OrderHistory);

--What books are associated with each publisher?


SELECT PublisherName, BookTitle FROM Books;

--What are the most popular products besides books that are sold in each store?
SELECT ProductID
FROM OrderHistory
WHERE ProductID NOT IN (SELECT BookID FROM Books);

--From what region s by zipcode do customers visit our store?


SELECT CustZipcode FROM Customer
WHERE CustomerID IN (SELECT CustomerID FROM Order);

Вам также может понравиться