X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 73B4D8BA1B6 for ; Fri, 11 Feb 2005 13:25:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92089-04 for ; Fri, 11 Feb 2005 13:25:02 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 43AE48BA1BE for ; Fri, 11 Feb 2005 13:24:57 +0000 (GMT) Received: (qmail 5665 invoked by uid 500); 11 Feb 2005 13:39:53 -0000 Date: Fri, 11 Feb 2005 07:39:53 -0600 From: Bruno Wolff III To: David Goodenough Cc: pgsql-general@postgresql.org Subject: Re: SQL query Message-ID: <20050211133953.GB5110@wolff.to> Mail-Followup-To: David Goodenough , pgsql-general@postgresql.org References: <200502111107.25004.david.goodenough@btconnect.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200502111107.25004.david.goodenough@btconnect.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/639 X-Sequence-Number: 73443 On Fri, Feb 11, 2005 at 11:07:24 +0000, David Goodenough wrote: > > I thought of using an inner select for the join, and using limit 1 to > get just the one, and forcing the order by to give me the billing > address by preference, but I am then dependant on the sort order > of the particular type values I am selecting from. You can order by boolean expressions such as type = 'billing'. You can use that with LIMIT or DISTINCT ON to get just the address you want.