Your question is Books in Good Condition and Renewal Rate. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Meta Library tracks physical book copies and their current loan records. Write a PostgreSQL query to determine how many copies are in good condition and currently not returned, then calculate what percentage of those copies have been renewed more than two times.
condition is good and returned_at is NULL.NULL renewal count as zero and avoid division-by-zero errors.| Column | Type | Description |
|---|---|---|
| book_idPK | INT | Unique identifier for a book title |
| title | VARCHAR(200) | Book title |
| author | VARCHAR(150) | Author name |
| Column | Type | Description |
|---|---|---|
| copy_idPK | INT | Unique identifier for a physical copy |
| book_id | INT | Book title associated with the copy |
| condition | VARCHAR(20) | Current physical condition |
| Column | Type | Description |
|---|---|---|
| loan_idPK | INT | Unique identifier for a loan |
| copy_id | INT | Physical copy on loan |
| returned_at | DATE | Date returned, or null for an active loan |
| renewal_count | INT | Number of times the loan was renewed |