How to fetch a list of distinct IDs using one query and then feed this list as an input parameter for IN() or ANY() of another query in Postgres.
(SELECT DISTINCT id FROM inventory WHERE supplier_id = 37) AS idlist
(SELECT SUM(item_price) FROM transaction WHERE person_id IN (idlist)) AS output
NOTE: Specifically, I don't want to use subquery as a constraint in WHERE clause as proposed in some of the answers below. And I don't want to use nested subqueries.