Here is my code, I am trying to get the total sum of prices of books which appear in the order made by 'Village bookshop'
on the '27/09/2018'
Relevant tables
book(isbn, title, authorID, genre, pubYear, publisher, rrPrice, avgRating)
bookShop(shopNo, shopName, street, city, county)
orders(orderNo, sNo, oDate, salesRep)
orderDetails(oNo, bookISBN, quantity)
My question is, is there a more efficient way than a subquery to do this?
SELECT sum(rrPrice)
FROM book
WHERE isbn in(
SELECT bookISBN
FROM orderDetails INNER JOIN orders ON orderNO = oNO
INNER JOIN bookShop on sNO = shopNo
WHERE shopName = 'Village bookshop' and oDate='27/09/2018'
)