Library database SQL: unreturned copies, top books and referral gaps
A library schema has tables for books, copies, members, checkouts, reservations and authors. Write the queries:
- How many copies are in good condition and not yet returned? Among them, what share were renewed more than twice?
- Among books with more than ten copies, return the three with the longest total time on loan (return date minus checkout date, summed over their lifetime).
- Members can refer other members. Find the member with the largest difference in reserved books between them and the member who referred them, and that difference.
A data engineering screen: about 25 minutes of SQL like this, then Python, with only a few minutes per question.
No answer yet. Write the first one; the best answer gets endorsed.
