我的尝试如下:
SELECT BookLoan.borrowerName, Book.cost
FROM BookLoan
JOIN Book ON BookLoan.bookTitle = Book.title
JOIN Borrower ON BookLoan.borrowerName = Borrower.name;
我需要按
borrowerName
组合总费用,但真的不确定如何? 最佳答案
SELECT BookLoan.borrowerName, SUM(Book.cost) as TotalCost
FROM BookLoan
JOIN Book ON BookLoan.bookTitle = Book.title
JOIN Borrower ON BookLoan.borrowerName = Borrower.name
GROUP BY BookLoan.borrowerName