(在PostgreSQL 9中测试过)
标识摆脱和时间戳。
select rid, max(timestamp) as tsfrom testgroup by rid;1 2011-04-14 18:46:002 2011-04-14 14:59:00
加入吧。
select test.pid, test.cost, test.timestamp, test.ridfrom testinner join (select rid, max(timestamp) as ts from test group by rid) maxton (test.rid = maxt.rid and test.timestamp = maxt.ts)



