I have two tables
BOOK(book_id, book_name) and
COPY(copy_id, book_id, available(bool)) I want to have a query to display book_id, book_name, and COUNT(*) of all copies with the same book_id in COPY table that have available set to true. Sample query output should look like this:
1, BookA, 2 2, BookB, 4 3, BookC, 0 So BookA has two COPY tuples with available set to true. This is what I have so far, it doesn't work.
SELECT * FROM (SELECT * FROM BOOK)book, (SELECT book_id, COUNT(copy_id) FROM COPY)copy WHERE book.book_id = copy.book_id;