X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A2D96D1B4E4 for ; Sun, 7 Sep 2003 14:22:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04136-07 for ; Sun, 7 Sep 2003 11:22:46 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 88B11D1B530 for ; Sun, 7 Sep 2003 11:22:42 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h87EMXAn025821; Sun, 7 Sep 2003 10:22:33 -0400 (EDT) To: Rod Taylor Cc: Alexei Chetroi , Pgsql-Sql Subject: Re: SQL subqueries newbie help In-reply-to: <1062940175.54737.22.camel@jester> References: <20030906110709.GA13384@uniflux-line.net> <1062868895.54737.3.camel@jester> <20030907114226.GA22231@uniflux-line.net> <1062940175.54737.22.camel@jester> Comments: In-reply-to Rod Taylor message dated "Sun, 07 Sep 2003 09:09:35 -0400" Date: Sun, 07 Sep 2003 10:22:33 -0400 Message-ID: <25820.1062944553@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/44 X-Sequence-Number: 15022 Rod Taylor writes: > Oh yeah, sorry. It needs to be like that because otherwise it is unsure > what value to use for event. What you really want is a min function > that runs a min on date, and returns the appropriate event -- which > doesn't exist, but I believe could be created SELECT DISTINCT ON might provide a simpler solution to that requirement. Check out the "weather reports" example in the SELECT reference page. regards, tom lane