X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C7682D1E0CE for ; Thu, 19 Feb 2004 19:35:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91218-05 for ; Thu, 19 Feb 2004 15:35:04 -0400 (AST) Received: from diver.highboard.com (ns5.highboard.com [207.44.244.101]) by svr1.postgresql.org (Postfix) with ESMTP id 0E10FD1D29F for ; Thu, 19 Feb 2004 15:35:03 -0400 (AST) Received: from roc-66-67-208-52.rochester.rr.com ([66.67.208.52] helo=swimmer) by diver.highboard.com with asmtp (Exim 4.24) id 1Attx0-0004yY-Ad for pgsql-sql@postgresql.org; Thu, 19 Feb 2004 14:35:10 -0500 Reply-To: From: "Jeremy Smith" To: Subject: Re: DISTINCT ON troubles Date: Thu, 19 Feb 2004 14:34:39 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <200402191128.51124.josh@agliodbs.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - diver.highboard.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - highboard.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/286 X-Sequence-Number: 16976 Thanks Josh, I'll do that, I just wasn't sure if I was missing something obvious. Jeremy -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com] Sent: Thursday, February 19, 2004 2:29 PM To: jer@highboard.com; pgsql-sql@postgresql.org Subject: Re: [SQL] DISTINCT ON troubles Jeremy, > Am I just approaching this all wrong and need to create a temporary table > and draw from that, or is there a way to salvage this query? Think about using a subquery instead of the DISTINCT ON approach. I don't think you can get what you want with DISTINCT ON. A temporary table is not necessary. -- -Josh Berkus Aglio Database Solutions San Francisco