RienSQL
TASK #127 · Hard · Cian

User last 3 borrowed works and total times taken

Your brief
In the library system, the OperationLogs table records book borrowing and return operations. Each record contains information about which user took which book copy and when.

For each user, find their last three borrowings; if a user borrowed the same work more than once, it may appear several times. For each of those works, indicate the user (user_id), the work title (book_title) and how many times it was borrowed in total (by all users throughout history) (total_times_taken).
Expected columnsuser_id book_title total_times_takenCian
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
Booksid, title
BookEditionsid, book_id, publish_year, pages
BookCopiesid, edition_id, inventory_number
OperationLogsid, user_id, copy_id, date_taken, date_returned