Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 961B2633873 for ; Wed, 18 Nov 2009 20:20:59 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 22034-08 for ; Thu, 19 Nov 2009 00:20:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f189.google.com (mail-qy0-f189.google.com [209.85.221.189]) by mail.postgresql.org (Postfix) with ESMTP id 71E016336C4 for ; Wed, 18 Nov 2009 20:20:48 -0400 (AST) Received: by qyk27 with SMTP id 27so968788qyk.20 for ; Wed, 18 Nov 2009 16:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:references:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:x-mailer :mime-version:subject:date:cc; bh=WXhscRxTOzCjdfp9i08pt9/6Jb0QNENWiFuyTEzDPD8=; b=THwHY6ACtMhI+rDDCQZQ7FIWIMgB86KLW2ImIYVuYZPKUrKw9v9pIgDVAQn3sGgk3c 15VD9cO8Bqbj5hMLIu6s/725xXWbqQuhYx6AoGUmybn0JMqN725pBo1ISbUzqYt7oeJA kQuCCJau2vExD3FKtqJ/Avum2rkzFbLf8eCm8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:x-mailer:mime-version:subject:date:cc; b=IjAgY4Tl+TmEqhBm6IHldS7gMTyf1HjjCFKp3XYq2ar1gsgrMv9GozJG5GYFnTPPyf syoUgodsXkyEa/uXslA2x8FFaPPZ4nafTbHgOFdlTR9pXZjkuMe6yIfFRuXlQ6VBEJ0K EAO4msROr/lnl+uBN2nMfyHO2Um7XWwzbdNN0= Received: by 10.224.31.8 with SMTP id w8mr6797311qac.49.1258590046368; Wed, 18 Nov 2009 16:20:46 -0800 (PST) Received: from ?192.168.11.100? (bas1-toronto63-1096773806.dsl.bell.ca [65.95.112.174]) by mx.google.com with ESMTPS id 22sm21741qyk.2.2009.11.18.16.20.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 18 Nov 2009 16:20:45 -0800 (PST) References: <5ab13580911181121g6e89759doa6c6ea6557424f71@mail.gmail.com> <200911182027.08857.guillaume@lelarge.info> Message-Id: From: Kris Kewley To: Guillaume Lelarge In-Reply-To: <200911182027.08857.guillaume@lelarge.info> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable X-Mailer: iPod Mail (5H11a) Mime-Version: 1.0 (iPod Mail 5H11a) Subject: Re: LIMIT BASED ON PERCENT Date: Wed, 18 Nov 2009 19:20:24 -0500 Cc: "pgsql-sql@postgresql.org" , Another Trad , Lee Hachadoorian X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/58 X-Sequence-Number: 33409 Could you not create a function to do this instead? Set var_limit =3D 20% of row count Replace subquery with var_limit Kris On 18-Nov-09, at 14:27, Guillaume Lelarge =20 wrote: > Le mercredi 18 novembre 2009 =C3=A0 20:24:09, Another Trad a =C3=A9crit = : >> No, It doesn't. >> In my machine: >> >> First select >> ERROR: syntax error at end of input >> LINE 1: select * from rapadura.cliente limit 20% >> ^ >> Second one: >> ERROR: argument of LIMIT must not contain subqueries >> >> Postgres 8.3 >> > > It works for Lee because obviously he's working on a 8.4 server. You =20= > can use > subquery in a LIMIT clause if you have an 8.4 PostgreSQL server. For =20= > earlier > releases, there's no way to do this in a single query. > > > --=20 > Guillaume. > http://www.postgresqlfr.org > http://dalibo.com > > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql