Re: LIMIT BASED ON PERCENT - Mailing list pgsql-sql

From Pavel Stehule
Subject Re: LIMIT BASED ON PERCENT
Date
Msg-id 162867790911181130n74be837eo29e3c408724c88f7@mail.gmail.com
Whole thread Raw
In response to Re: LIMIT BASED ON PERCENT  (Guillaume Lelarge <guillaume@lelarge.info>)
Responses Re: LIMIT BASED ON PERCENT  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
List pgsql-sql
2009/11/18 Guillaume Lelarge <guillaume@lelarge.info>:
> Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit :
>> 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 can use
> subquery in a LIMIT clause if you have an 8.4 PostgreSQL server. For earlier
> 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 foo)

Regards
Pavel


>
> --
> Guillaume.
>  http://www.postgresqlfr.org
>  http://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
>


pgsql-sql by date:

Previous
From: Another Trad
Date:
Subject: Re: LIMIT BASED ON PERCENT
Next
From: Lee Hachadoorian
Date:
Subject: Re: LIMIT BASED ON PERCENT