First()/last() aggregates in Postgres
wiki.postgresql.org