This is really an SQL question, not specific to PostgreSQL. I have a table:
ValTable
======
id int
ext_id int
value float
For each ext_id (which references something in another table), I want to
find the row with the minimum value. The best I can come up with is:
SELECT * FROM ValTable AS v
WHERE v.value = (
SELECT DISTINCT min(value) FROM ValTable
WHERE ext_id = v.ext_id
)
I feel like there has to be a way to do it without a nested query, probably
using GROUP BY. Any thoughts?
--Greg