The relation between the two tables is,
CREATE TABLE library_branch
(
branchID NUMBER,
branchName varchar(20),
address varchar(20),
PRIMARY KEY(branchID)
)
CREATE TABLE book_loan
(
bookID varchar(20),
branchID NUMBER,
cardNo NUMBER,
dateOut DATE,
dueDate DATE,
PRIMARY KEY(bookID, branchID, cardNo),
FOREIGN KEY(branchID) REFERENCES library_branch(branchID)
)
The question is: for each library branch, retrieve the branch name and the total number of books loaned out from that branch
I have written a query to find out which library branch loaned which books but can't figure out how to find how many books were loaned by each library branch.
Any help to solve this problem will be appreciated.