Deviopath › PostgreSQL

Members in Good Standing

Medium · Subqueries

EXISTS (subquery) is true when the subquery returns at least one row, and NOT EXISTS is true when it returns none. The subquery can refer to the outer row, like WHERE l.member_id = m.id.

A loan is still open when returned_on is NULL. Return the name of every member who has borrowed at least one book and has no open loans. Sort by name.

Next: Raise Prices and Report Back