Write SQL for library analytics
Company: Meta
Role: Data Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Technical Screen
Given a library database, write SQL to answer the following:
1) Count the number of books that are currently not returned (i.e., still checked out) and are in good condition.
2) Among those currently not returned and in good condition, compute the percentage that have been renewed more than 2 times (use that subset as the denominator).
3) Return the top 3 book titles or IDs that have more than 10 copies and the longest total lending time across all their loans (sum of loan durations).
4) Find the member–referrer pair with the greatest difference in the number of reservations they have made, and return the pair and the difference.
Quick Answer: This question evaluates proficiency in SQL-based data manipulation and analytical querying, focusing on relational schema navigation, joins, aggregation, filtering, and handling temporal and conditional metrics within a library dataset.