brianchan.us
Get the First or Last Value in a Group Using Group By in SQL
Sample code in PostgreSQL ref: