Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6QLoMf36752 for ; Thu, 26 Jul 2001 17:50:22 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 92249; Thu, 26 Jul 2001 14:50:14 -0700 From: "Josh Berkus" Subject: Re: Restriction by grouping problem. To: "Jeff Barrett" Cc: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Thu, 26 Jul 2001 14:50:14 -0700 Message-ID: In-Reply-To: <9jq14a$ft8$1@news.tht.net> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200107/351 X-Sequence-Number: 4165 Jeff, > The query I have now: > > SELECT min(datettime), sid FROM logs GROUP by sid; > > This returns the first instance of an sid in the logs table, there > can be > many rows in the table for each sid. The problem I have is that I do > not > need the SID I just need to group the min(datetime) by it. The answer to this question is simple: SELECT min(datetime) as mintime FROM logs GROUP BY sid; However, I get the impression that your intended problem was more complicated. Can you re-explain it? -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco