X-Original-To: pgsql-sql@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 4F5864762A2 for ; Wed, 5 Mar 2003 10:22:44 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id C7A671381F1; Wed, 5 Mar 2003 10:22:47 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18qajH-00025r-00; Wed, 05 Mar 2003 10:22:47 -0500 To: Christoph Haller Cc: pgsql-sql@postgresql.org, cprice@hrdenterprises.com Subject: Re: LIMIT and SUBQUERIES References: <3E65FA8B.352136E@rodos.fzk.de> In-Reply-To: <3E65FA8B.352136E@rodos.fzk.de> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 05 Mar 2003 10:22:46 -0500 Message-ID: <87fzq196t5.fsf@stark.dyndns.tv> Lines: 25 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/159 X-Sequence-Number: 12199 Christoph Haller writes: > > > > So anyway, I have the query that is working - but it returns all > > records for all owners, when what I really want to do is return the > > top 5 per each owner. > > > I've seen a lot of questions like this on the list before about > filtering > result sets. Within the most replies, people were told to use middleware > > stuff like perl, awk, sed, ... to filter out unwanted rows, because SQL > was not intended to do so. This is the same problem as the "ranking" problem that I mentioned earlier. http://archives.postgresql.org/pgsql-sql/2003-03/msg00013.php Essentially we would need a kind of feature that has some similarities to user defined aggregates but is not exactly the same thing. The feature doesn't currently exist, and I haven't seen it in order databases, so I don't even know exactly what it would look like. -- greg