Reputation: 225
BOOK_COPIES (Book_ISBN [pk,fk], Branch_ID [pk,fk], Num_Copies)
BOOK_LOANS (Book_ISBN [pk,fk], Branch_ID [pk,fk],Card_Num [pk,fk], Date_Out, Date_Due)
LIBRARY_BANCH (Branch_ID [pk], Branch_Name, Address)
Q. For each branch list the branch ID and the number of books they have. This is the
total number of books including multiple copies.
solution: select lb.branchid from library branch lb,bookcopies bc where bc.branchid=b.branchid group by lb.branchid;
However I'm finding it difficult to get the number of books they have?
Upvotes: 0
Views: 389
Reputation: 57573
Try this, it should work:
SELECT Branch_ID, SUM(Num_Copies) totcopies
FROM BOOK_COPIES
GROUP BY Branch_ID
Upvotes: 2