On Mon, Aug 27, 2007 at 06:36:47PM +0200, Claudia Kosny wrote: > Is there a way to do this with one query? > I am using PostgreSQL 7.4.
you can try to use "distinct on". depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.depesz.com/ - blog dla ciebie (i moje CV) ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match