Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 96BCC9FB5B2 for ; Sat, 17 Feb 2007 13:47:33 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 28962-01-2 for ; Sat, 17 Feb 2007 13:47:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 24C859FB603 for ; Sat, 17 Feb 2007 13:47:27 -0400 (AST) Received: from a-kretschmer.de (p54B3ABD0.dip0.t-ipconnect.de [84.179.171.208]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id l1HHlHnp031783 for ; Sat, 17 Feb 2007 18:47:17 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.61) (envelope-from ) id 1HITex-0008Hi-Pm for pgsql-sql@postgresql.org; Sat, 17 Feb 2007 18:47:43 +0100 Date: Sat, 17 Feb 2007 18:47:43 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: sub-limiting a query Message-ID: <20070217174743.GA30380@KanotixBox> References: <20070217125634.GA20589@apartia.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20070217125634.GA20589@apartia.fr> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.645 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/186 X-Sequence-Number: 27520 Louis-David Mitterrand schrieb: > ballet,etc.) and I am looking for a select that can return the 10 last > entered shows AND at most 2 of each type. Is that possible in one query? A similar question i found in the archive and there are a couple of answers: (for the second part of your question) http://archives.postgresql.org/pgsql-sql/2005-03/msg00408.php But as i said, there is no plain sql-solution. Unfortunately we haven't windowing functions, but perhaps in the future, Gavin Sharry is working on this. Take a look at http://www.gavinsherry.org/blog/index.php?/archives/7-Window-function-presentation.html Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°