On Thu, 20 Sep 2001, Tom Lane wrote:
> This is what SELECT DISTINCT ON was invented for. I don't know any > comparably easy way to do it in standard SQL, but with DISTINCT ON > it's not hard: > > SELECT DISTINCT ON (userid) userid, val, ts FROM table > ORDER BY userid, ts DESC; > > See the DISTINCT ON example in the SELECT reference page for more info: > http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/sql-select.html Thanks! I was trying some stuff with distinct on, but in combination with max(ts), which obviously didn't work. Now it works much better =) /Patrik Kudo ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])