On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote: > > > esdt=> explain analyze select PlayerID,AtDate from Player a > > > where PlayerID='22220' and AtDate = (select b.AtDate from Player b > > > where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc > > > LIMIT 1);
I think you should try: select distinct on (PlayerID) PlayerID,AtDate from Player a where PlayerID='22220' order by PlayerId, AtDate Desc; Does that work for you? Best Regards, Simon Riggs ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org