Assignment 2
Assignment 2
Please follow the instructions below to complete the assignment. Instructions 1 to 4 have got
2 points each and 5 to 8 have got 3 points each.
Download the attached file, Ch07_Fact_MySQL.sql and run the scripts to create the tables and
insert the data. The tables follow ERD below:
CHECKOUT MEMBER
BOOK AUTHOR
WRITES
1. Write a query that displays the member Id, first and last name, and member type for all
members whose last name begins with the letter ‘B’ sorted by member Id.
2. Write a query that displays the author Id, first and last name of every author, and the
author’s birth year for all those authors who are at least 40 years old.
3. Write a query that displays the book num, book title, year, cost for all those books that have
‘programming’ anywhere on the title.
4. Write a query to display book number, first and last name of member and days kept for
each checkout. “Days Kept” is the difference from the date on which the book is returned
to the date it was checked out. Sort the results by days kept in descending order and then
by book number.
5. Write a query to display the lowest/minimum average cost of books [66.61666] within a
subject and the highest/maximum average cost of books [89.50000] within a subject.
Round the cost values to nearest smallest integer.
6. Write a query to display the member Id and the average number of days that the member
keeps books during a checkout. Limit the results to only those members who have at least
three checkouts. Sort the results in descending order by the average days the book is kept.
7. Write a query to display the author’s Id, first and last name as well as member’s Id, first
and last name where last name of author starts with P and the last name of member begins
with M. Sort the result by the Id attribute.
8. Write a query to display the book title, book year and book cost converted to integer for
books that do not have ‘data’ in the book title and are published before 2016 having book
cost over $50. Sort the results by book cost.