Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9E372632ADB for ; Wed, 18 Nov 2009 15:31:09 -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 18694-09 for ; Wed, 18 Nov 2009 19:30:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f218.google.com (mail-gx0-f218.google.com [209.85.217.218]) by mail.postgresql.org (Postfix) with ESMTP id D16746329B9 for ; Wed, 18 Nov 2009 15:30:58 -0400 (AST) Received: by gxk10 with SMTP id 10so1378146gxk.3 for ; Wed, 18 Nov 2009 11:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=58dxv/oDuLm2Q7qg0NurW/2JcnEJ31bXYMSg5obHwOo=; b=Bodg/EWTL8v2tLvEyW5uvCb7qylUwChZsvZlgrth+J5liBXXRc3A6oBIruc0xEIVpr ockhU06u8rZpCHo+++YHe1rPNkIcZl0JhJ8LiZMneVo7rkEFH52Je6s76rFj0/svYYiR y3WFrc3p69tCc/QuZPDW7Zoqnvd1qnsw8CYL8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Y6FpVmL6M0WmvQgoB5F4qGV7vLJia9+zeC+AF2gzaagB/Z1aMCGOeGIBE9RdglKlw7 3S/99nNklfMyvSHWB9ERJRUwbUknYplIXhDfn4zMHmDx/SmL3PWX9j26yJRVKLD7OCAB iib31cazI1Hqg2mBHyerBiAMORGkjTooI9Exk= MIME-Version: 1.0 Received: by 10.150.45.37 with SMTP id s37mr2947029ybs.281.1258572656962; Wed, 18 Nov 2009 11:30:56 -0800 (PST) In-Reply-To: <200911182027.08857.guillaume@lelarge.info> References: <5ab13580911181121g6e89759doa6c6ea6557424f71@mail.gmail.com> <200911182027.08857.guillaume@lelarge.info> Date: Wed, 18 Nov 2009 20:30:56 +0100 Message-ID: <162867790911181130n74be837eo29e3c408724c88f7@mail.gmail.com> Subject: Re: LIMIT BASED ON PERCENT From: Pavel Stehule To: Guillaume Lelarge Cc: pgsql-sql@postgresql.org, Another Trad , Lee Hachadoorian Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.575 tagged_above=-10 required=5 tests=AWL=0.024, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/54 X-Sequence-Number: 33405 2009/11/18 Guillaume Lelarge : > 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: =C2=A0syntax error at end of input >> LINE 1: select * from rapadura.cliente limit 20% >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ^ >> Second one: >> ERROR: =C2=A0argument of LIMIT must not contain subqueries >> >> Postgres 8.3 >> > > It works for Lee because obviously he's working on a 8.4 server. You can = use > subquery in a LIMIT clause if you have an 8.4 PostgreSQL server. For earl= ier > releases, there's no way to do this in a single query. > yes, and don't use 20%. select * from foo order by somecol limit (select (count(*)*0.2)::int from f= oo) Regards Pavel > > -- > Guillaume. > =C2=A0http://www.postgresqlfr.org > =C2=A0http://dalibo.com > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >