'seq' is in lieu of a timestamp; I didn't do the max() testing. Gotta git to bed. :-)

\nforum=> create table atest (box integer, pname text, pval text, seq integer);\nCREATE\nforum=> insert into atest values (1, 'foo', 'fooval', 1);\nINSERT 16989 1\nforum=> insert into atest values (1, 'bar', 'barval', 1);\nINSERT 16990 1\nforum=> insert into atest values (2, 'foo', 'fooval 2', 1);\nINSERT 16991 1\nforum=> insert into atest values (2, 'bar', 'barval 2', 1);\nINSERT 16992 1\n\nforum=> select atest.box, atest.pval, a.pval \nfrom atest, (select box, pval from atest where pname = 'bar') as a \nwhere atest.box = a.box and atest.pname = 'foo';\n\n box |   pval   |   pval   \n-----+----------+----------\n   1 | fooval   | barval\n   2 | fooval 2 | barval 2\n(2 rows)\n