Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 7A2B29FB531 for ; Sat, 17 Feb 2007 08:56:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 79025-01 for ; Sat, 17 Feb 2007 08:56:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from zenon.apartia.fr (zenon.apartia.fr [82.66.93.83]) by postgresql.org (Postfix) with ESMTP id 7CB609FB505 for ; Sat, 17 Feb 2007 08:56:36 -0400 (AST) Received: from styx.apartia.fr (styx.apartia.fr [10.0.3.109]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "styx.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by zenon.apartia.fr (Postfix) with ESMTP id 75E86F4B73401 for ; Sat, 17 Feb 2007 13:56:34 +0100 (CET) Received: by styx.apartia.fr (Postfix, from userid 1000) id 201F8B2AE50B; Sat, 17 Feb 2007 13:56:35 +0100 (CET) Date: Sat, 17 Feb 2007 13:56:35 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: sub-limiting a query Message-ID: <20070217125634.GA20589@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.945 tagged_above=0 required=5 tests=BAYES_50, RCVD_IN_NJABL_DUL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: * X-Archive-Number: 200702/181 X-Sequence-Number: 27515 Hello, I've got a table of shows with different types (movie, theater, 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? The table looks basically like: created_on | timestamp without time zone show_name | text id_show | integer show_type | text id_show_subtype | integer