Comment Comment by e12e Doesn't DISTINCT work in this case? SELECT DISTINCT ON (vt.id) row_to_json(vt.*) FROM vt JOIN vy ON vt.id = vy.tid WHERE vt.id = 1 AND vy.amount > 1; parent e12e 5 years ago