I have a set of records that is a list of borrowed books (book_id) and the borrower's details (member_id, category).
Each borrower belongs to a membership category (ie, Student, Teacher, Pensioner).
We want to write a query to identify, for each book, how many times it was borrowed by
members of each category:
Book A = 2 x teacher loans,
Book A = 5 x student loans,
Book A =3 x Pensioner loans.
Book C = 4 x teacher loans,
Book C = 0 x student loans,
Book C = 8 x Pensioner loans
Could we also identify books that had only ever been borrowed by members of one category (ie, Book B has only ever been borrowed by Teachers)?
Book B = 4 x teacher loans,
Book B = 0 x student loans,
Book B = 0 x Pensioner loans
Another variation of this could be, which books have never been borrowed by members of a certain category
(books that have never been borrowed by a student)?
Book B = 0 x student loans,
Book C = 0 x student loans,
Thanks for any help or suggestions as to the best way to write these queries.
Each borrower belongs to a membership category (ie, Student, Teacher, Pensioner).
We want to write a query to identify, for each book, how many times it was borrowed by
members of each category:
Book A = 2 x teacher loans,
Book A = 5 x student loans,
Book A =3 x Pensioner loans.
Book C = 4 x teacher loans,
Book C = 0 x student loans,
Book C = 8 x Pensioner loans
Could we also identify books that had only ever been borrowed by members of one category (ie, Book B has only ever been borrowed by Teachers)?
Book B = 4 x teacher loans,
Book B = 0 x student loans,
Book B = 0 x Pensioner loans
Another variation of this could be, which books have never been borrowed by members of a certain category
(books that have never been borrowed by a student)?
Book B = 0 x student loans,
Book C = 0 x student loans,
Thanks for any help or suggestions as to the best way to write these queries.