Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D23EF9FA2CB for ; Mon, 20 Nov 2006 13:48:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 80245-05 for ; Mon, 20 Nov 2006 13:48:35 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 62F209F9ED7 for ; Mon, 20 Nov 2006 13:48:35 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1GmDK3-0004A9-Rv for pgsql-sql@postgresql.org; Mon, 20 Nov 2006 12:52:47 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 843944172; Mon, 20 Nov 2006 12:48:22 -0500 (EST) Date: Mon, 20 Nov 2006 12:48:22 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: How to find out top 3 records in each location Message-ID: <20061120174822.GB29317@phlogiston.dyndns.org> References: <00e001c70cc6$926292a0$6f0aa8c0@miswen> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00e001c70cc6$926292a0$6f0aa8c0@miswen> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/215 X-Sequence-Number: 26867 On Mon, Nov 20, 2006 at 12:09:00PM -0500, wen tseng wrote: > > Since PostgreSQL doesn't support TOP, how can I do to get this result? > Any solution will be appreciated. Check out the crosstab stuff in contrib/; I think it does what you want. a -- Andrew Sullivan | ajs@crankycanuck.ca The whole tendency of modern prose is away from concreteness. --George Orwell