I was able to get this far but what I can't figure is how list the name of the branch before the results of the count().
I also need a way to show all branches and the amount of loaned books to that specific branch all at the same time. If anyone could help me with this that would be amazing, thank you!
Results looking like "Branch Name".. "Number of loaned books" "Next Branch".. "Number of loaned books"
Code:
select count(bookLoans.bookID) from bookLoans
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID
where libraryBranches.branchName = 'Sharpstown'
I'm not sure of what you're trying to do, but I'll try to answer.
For your first question, you just need to add the branchName in your "select", and add a "group by" at the end of the request :
select libraryBranches.branchName, count(bookLoans.bookID) from bookLoans
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID
where libraryBranches.branchName = 'Sharpstown'
group by libraryBranches.branchName;
To get all the branches in the result, just remove the "where" part. You can add an "order by" at the end if needed :
select libraryBranches.branchName, count(bookLoans.bookID) from bookLoans
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID
group by libraryBranches.branchName
order by libraryBranches.branchName;