Using the Microsoft Access database Books, write SQL statements for the followin
ID: 3773050 • Letter: U
Question
Using the Microsoft Access database Books, write SQL statements for the following tasks. Once complete, copy the SQL statements from Microsoft Access and paste them in a Microsoft Word document that will be submitted along with part II of the assignment.
Write an SQL statement to display the publication ID, publication date, cost, and category of each book planned for publication ID number 4.
Repeat the previous task but include ID and Date as column aliases for the first two columns.
Write an SQL statement to display the least expensive retail price book in each book category.
Repeat the previous task but sort the displayed categories in the descending order.
Write an SQL statement to display the customer number, city of destination, and shipping date for all shipments with order number above 2. (Hint: Use the Orders table.)
Repeat the previous task but further restrict the output to shipping dates after January 1, 2013. (Hint: The date restriction will require a format identical to the one displayed in the previous task, and it must be surrounded by pound signs—#01/01/2013# for example.)
Write an SQL statement to display the publication ID, average retail price, and average cost of all books. Group the output by publication ID.
Write INSERT statements to add the following data to the Publisher table:
Write a single SELECT statement that will verify the records inserted.
Write a DELETE statement to remove only the new BOOK BUSTER record
PubID Name Contact Phone 6 READ WITH US John Doe 866-888-9999 7 KNOWLEDGE FOR ALL Jane Doe 800-1212-5555 8 CHEAP PUBLISHING Tom Smith 000-321-4071 9 TEXT AND MORE John Carter 032-100-7777 10 BOOK BUSTER George Stevens 777-555-1212Explanation / Answer
1.Write an SQL statement to display the publication ID, publication date, cost, and category of each book planned for publication ID number 4.
Select pubID, pubDate, Cost, Category from Books where PubID=4;
Repeat the previous task but include ID and Date as column aliases for the first two columns.
Select pubID as ID, pubDate as Date, Cost, Category from Books where PubID=4;
2. Write an SQL statement to display the least expensive retail price book in each book category.
Select Category, min(Rentail) as Rentail from Books group by Category;
Repeat the previous task but sort the displayed categories in the descending order.
Select Category, min(Rentail) as Rentail from Books group by Category order by Category desc;
3. Write an SQL statement to display the customer number, city of destination, and shipping date for all shipments with order number above 2. (Hint: Use the Orders table.)
Select O.CustomerID, C.City, '#'+O.ShippingDate+'#' as Shipping Date, O.OrderID from Order O, Customer C where OrderID>2 and O.CustomerID=C.CustomerID;
Repeat the previous task but further restrict the output to shipping dates after January 1, 2013.
Select O.CustomerID, C.City,'#'+O.ShippingDate+'#' as Shipping Date, O.OrderID from Order O, Customer C where OrderID>2 and O.CustomerID=C.CustomerID and O.ShippingDate > '01/01/2013';
4. Write an SQL statement to display the publication ID, average retail price, and average cost of all books. Group the output by publication ID.
Select PubID, avg(Rentail) as Average Rentail, avg(Cost) as Average Cost from Books group by PubID;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.