SELECT b.id, b.title,
CASE WHEN b.id NOT IN (SELECT ib.book_id FROM issued_book ib)
OR (b.id IN (SELECT ib.book_id FROM issued_book ib) AND ib.date_return IS NOT NULL) THEN 'В наличии'
ELSE 'Нет в наличии'
END AS Наличие
FROM book b
LEFT JOIN issued_book ib ON ib.book_id = b.id